Skip to content

Commit

Permalink
Update fy3e.py
Browse files Browse the repository at this point in the history
  • Loading branch information
BigShuiTai authored Apr 20, 2023
1 parent 73d1641 commit 6d95311
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions HY_Plotter/windReader/reader/fy3e.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

class FY3E(object):

def extract(fname, georange=(), band="C_band", test=False):
def extract(fname, georange=(), band="C_band", daily=False, test=False):
try:
init = h5py.File(fname, "r")
except Exception:
Expand All @@ -21,12 +21,21 @@ def extract(fname, georange=(), band="C_band", test=False):
lats, lons, data_spd, data_dir, data_time, sate_name, res = [], [], [], [], "", "", ""
return lats, lons, data_spd, data_dir, data_time, sate_name, res
# get values
fns = init.attrs["File Name"].decode('utf-8').split("_")
lons, lats = init[band]["wvc_lon"][:], init[band]["wvc_lat"][:]
data_spd, data_dir = init[band]["wind_speed_selected"][:], init[band]["wind_dir_selected"][:]
data_time = fns[7] + fns[8]
sate_name = init.attrs["Satellite Name"].decode('utf-8') \
+ " " + init.attrs["Sensor Name"].decode('utf-8')
if daily:
# WindRAD daily data (POAD)
fns = init.attrs["File Name"].split("_")
lons, lats = init[band]["grid_lon"][:], init[band]["grid_lat"][:]
data_spd, data_dir = init[band]["wind_speed_selected"][:], init[band]["wind_dir_selected"][:]
data_time = (fns[7] + fns[8]).replace('POAD', ' 00:00:00.0')
sate_name = init.attrs["Satellite Name"] \
+ " " + init.attrs["Sensor Name"]
else:
fns = init.attrs["File Name"].decode('utf-8').split("_")
lons, lats = init[band]["wvc_lon"][:], init[band]["wvc_lat"][:]
data_spd, data_dir = init[band]["wind_speed_selected"][:], init[band]["wind_dir_selected"][:]
data_time = fns[7] + fns[8]
sate_name = init.attrs["Satellite Name"].decode('utf-8') \
+ " " + init.attrs["Sensor Name"].decode('utf-8')
if band == "C_band":
res = "20KM"
elif band == "Ku_band":
Expand All @@ -42,4 +51,4 @@ def extract(fname, georange=(), band="C_band", test=False):
else:
print("fy3e_hdf reader warning: content of HDF file is not FY-3E data")
lats, lons, data_spd, data_dir, data_time, sate_name, res = [], [], [], [], "", "", ""
return lats, lons, data_spd, data_dir, data_time, sate_name, res
return lats, lons, data_spd, data_dir, data_time, sate_name, res

0 comments on commit 6d95311

Please sign in to comment.