From e5716842160b88ad159312500813d9834701c3e5 Mon Sep 17 00:00:00 2001 From: zhangqiamkun Date: Thu, 22 Feb 2024 11:34:02 +0800 Subject: [PATCH] v1 --- ..._produce_GRAPES_4B_AGRI_background_data.py | 34 + AGRI/1_ARMS_make_config_AGRI_FY4B.py | 69 ++ AGRI/1_make_GRAPES_4B_AGRI_simulate_config.py | 32 + AGRI/2_ARMS_convert_HDF.py | 72 ++ AGRI/3_convert_GRAPES_4B_AGRI_hdf.py | 36 + AGRI/4_make_GRAPES_4B_AGRI_Filter.py | 39 + AGRI/run_GRAPES_4B_AGRI.py | 40 + GIIRS/0_combine_GRAPES_4B_GIIRS_2h_data.py | 40 + ...produce_GRAPES_4B_GIIRS_background_data.py | 52 ++ .../1_make_GRAPES_4B_GIIRS_simulate_config.py | 44 ++ GIIRS/3_convert_GRAPES_4B_GIIRS_hdf.py | 50 ++ .../4_split_GRAPES_4B_GIIRS_simulate_data.py | 42 + GIIRS/5_produce_GRAPES_4B_GIIRS_CLM_data.py | 126 +++ GIIRS/redo_GRAPES_4B_giirs.py | 26 + GIIRS/run_GRAPES_4B_giirs.py | 143 ++++ GRAPES.py | 104 +++ giirscombine/__init__.py | 330 ++++++++ giirscombine/__init__.pyc | Bin 0 -> 14012 bytes main.py | 69 ++ options/FY4A_giirs_options.yaml | 22 + options/FY4B_agri_options.yaml | 25 + options/FY4B_ghi_options.yaml | 25 + options/FY4B_giirs_options.yaml | 45 ++ options/FY4B_giirs_options_1.yaml | 40 + options/FY4B_giirs_options_test.yaml | 45 ++ options/__init__.py | 29 + options/__init__.pyc | Bin 0 -> 823 bytes options/background_options.yaml | 21 + options/girrscombine_options.yaml | 11 + options/spec_verify_options.yaml | 16 + utils.py | 722 ++++++++++++++++++ 31 files changed, 2349 insertions(+) create mode 100644 AGRI/0_produce_GRAPES_4B_AGRI_background_data.py create mode 100644 AGRI/1_ARMS_make_config_AGRI_FY4B.py create mode 100644 AGRI/1_make_GRAPES_4B_AGRI_simulate_config.py create mode 100644 AGRI/2_ARMS_convert_HDF.py create mode 100644 AGRI/3_convert_GRAPES_4B_AGRI_hdf.py create mode 100644 AGRI/4_make_GRAPES_4B_AGRI_Filter.py create mode 100644 AGRI/run_GRAPES_4B_AGRI.py create mode 100644 GIIRS/0_combine_GRAPES_4B_GIIRS_2h_data.py create mode 100644 GIIRS/0_produce_GRAPES_4B_GIIRS_background_data.py create mode 100644 GIIRS/1_make_GRAPES_4B_GIIRS_simulate_config.py create mode 100644 GIIRS/3_convert_GRAPES_4B_GIIRS_hdf.py create mode 100644 GIIRS/4_split_GRAPES_4B_GIIRS_simulate_data.py create mode 100644 GIIRS/5_produce_GRAPES_4B_GIIRS_CLM_data.py create mode 100644 GIIRS/redo_GRAPES_4B_giirs.py create mode 100644 GIIRS/run_GRAPES_4B_giirs.py create mode 100644 GRAPES.py create mode 100644 giirscombine/__init__.py create mode 100644 giirscombine/__init__.pyc create mode 100644 main.py create mode 100644 options/FY4A_giirs_options.yaml create mode 100644 options/FY4B_agri_options.yaml create mode 100644 options/FY4B_ghi_options.yaml create mode 100644 options/FY4B_giirs_options.yaml create mode 100644 options/FY4B_giirs_options_1.yaml create mode 100644 options/FY4B_giirs_options_test.yaml create mode 100644 options/__init__.py create mode 100644 options/__init__.pyc create mode 100644 options/background_options.yaml create mode 100644 options/girrscombine_options.yaml create mode 100644 options/spec_verify_options.yaml create mode 100644 utils.py diff --git a/AGRI/0_produce_GRAPES_4B_AGRI_background_data.py b/AGRI/0_produce_GRAPES_4B_AGRI_background_data.py new file mode 100644 index 0000000..653725d --- /dev/null +++ b/AGRI/0_produce_GRAPES_4B_AGRI_background_data.py @@ -0,0 +1,34 @@ +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--agriopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_agri_options.yaml', + help='Path to option YAML file.') + + parser.add_argument('--file','-f', type=str, + required = True, + help='Path to L1 file.') + + args = parser.parse_args() + agriopt = parse(args.agriopt) + + background = utils.bgbase(args.file,agriopt) + if background.match_nwp(): + background.make_config() + background.run() + else: + exit(1) diff --git a/AGRI/1_ARMS_make_config_AGRI_FY4B.py b/AGRI/1_ARMS_make_config_AGRI_FY4B.py new file mode 100644 index 0000000..64508b8 --- /dev/null +++ b/AGRI/1_ARMS_make_config_AGRI_FY4B.py @@ -0,0 +1,69 @@ +import os +import sys +import numpy as np +import datetime +import time +import glob + +sensor_ID = 'agri_fy4b' +def do_mywork(l1_file): + if '1330E' in l1_file: + l1_time = datetime.datetime.strptime(os.path.basename(l1_file),'FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_cloudy_profiles.dat') + if '1235E' in l1_file: + l1_time = datetime.datetime.strptime(os.path.basename(l1_file),'FY4B-_AGRI--_N_DISK_1235E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_cloudy_profiles.dat') + filepath = l1_time.strftime('/fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/FY4B/AGRI/GRAPES/%Y/%Y%m%d/') + if '1330E' in l1_file: + dat_file = l1_time.strftime('FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_cloudy_profiles.dat') + if '1235E' in l1_file: + dat_file = l1_time.strftime('FY4B-_AGRI--_N_DISK_1235E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_cloudy_profiles.dat') + + coef_filePath='/fy4_ads_data/stss_v2.0/workflow/Base/ARMS/fix/' + outpath=l1_time.strftime('/fy4_ads_data/stss_v2.0/Simulator/temp/FY4B/AGRI/ARMS/GRAPES/%Y/%Y%m%d/') + config_file = l1_time.strftime('/fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/configure_ARMS_FY4B_AGRI_%Y%m%d%H%M.txt') + OutputName = l1_time.strftime('FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M.h5') + try:os.makedirs(os.path.dirname(config_file)) + except:pass + try:os.makedirs(os.path.dirname(outpath)) + except:pass + print" <<", l1_file + print" <<", dat_file + print" >>", config_file + print" >>", outpath+OutputName + + with open(config_file,'w')as f: + f.write('&Sensorinfo\n') + f.write('Sensor_Id=\'%s\'' % sensor_ID +',\n') + f.write('/\n') + f.write('&L1info\n') + f.write('Datafilepath=\'%s\'' % filepath +',\n') + f.write('Datafilelist=\'%s\'' % dat_file +',\n') + f.write('File_Path=\'%s\'' % coef_filePath +',\n') + f.write('/\n') + f.write('&Output\n') + f.write('Outpath=\'%s\'' % outpath +',\n') + f.write('OutputName=\'%s\'' % OutputName + ',\n') + f.write('/\n') + # os.system('time ./ARMS_FWD_Test22 %s' % (config_file)) + os.system('time /fy4_ads_data/stss_v2.0/workflow/Base/ARMS/ARMS_FWD_H5 %s' % (config_file)) + if (os.path.exists(config_file)): + os.remove(config_file) +start_time = time.time() +files1 = sys.argv[1:] #/fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/FY4B/AGRI/GRAPES/2024/20240125/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_20240125200000_4000M_cloudy_profiles.dat +if not files1: + print( + """ + usage: + python {0} /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/FY4B/AGRI/GRAPES/2024/*/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_202401*_4000M_cloudy_profiles.dat + """.format(__file__)) +else: + import traceback + for k in files1: + do_mywork(k) +end_time = time.time() +duration = end_time - start_time + +# print("program run:", duration, "s") + + + + diff --git a/AGRI/1_make_GRAPES_4B_AGRI_simulate_config.py b/AGRI/1_make_GRAPES_4B_AGRI_simulate_config.py new file mode 100644 index 0000000..6cca5c9 --- /dev/null +++ b/AGRI/1_make_GRAPES_4B_AGRI_simulate_config.py @@ -0,0 +1,32 @@ +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--agriopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_agri_options.yaml', + help='Path to option YAML file.') + + parser.add_argument('--file','-f', type=str, + required = True, + help='Path to L1 file.') + + args = parser.parse_args() + agriopt = parse(args.agriopt) + + + simulate = utils.simbase(args.file,agriopt) + simulate.make_config() + + \ No newline at end of file diff --git a/AGRI/2_ARMS_convert_HDF.py b/AGRI/2_ARMS_convert_HDF.py new file mode 100644 index 0000000..5405d14 --- /dev/null +++ b/AGRI/2_ARMS_convert_HDF.py @@ -0,0 +1,72 @@ +#!/usr/bin/python +# coding=utf-8 +import os +import sys +import numpy as np +import h5py +import datetime +import time +import glob + +def hdfmake_agri(L1Filename): + if '1330E' in L1Filename: + l1_time = datetime.datetime.strptime(os.path.basename(L1Filename),'FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_cloudy_profiles.dat') + if '1235E' in L1Filename: + l1_time = datetime.datetime.strptime(os.path.basename(L1Filename),'FY4B-_AGRI--_N_DISK_1235E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_cloudy_profiles.dat') + outpath = l1_time.strftime('/4B_AS/sim/FY4B/AGRI/ARMS/GRAPES/%Y/%Y%m%d/') + if '1330E' in L1Filename: + save_file = l1_time.strftime('/4B_AS/sim/FY4B/AGRI/ARMS/GRAPES/%Y/%Y%m%d/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_BT.HDF') + if '1235E' in L1Filename: + save_file = l1_time.strftime('/4B_AS/sim/FY4B/AGRI/ARMS/GRAPES/%Y/%Y%m%d/FY4B-_AGRI--_N_DISK_1235E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M_BT.HDF') + h5filename = l1_time.strftime('/fy4_ads_data/stss_v2.0/Simulator/temp/FY4B/AGRI/ARMS/GRAPES/%Y/%Y%m%d/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_%Y%m%d%H%M00_4000M.h5') + try:os.makedirs(os.path.dirname(save_file)) + except:pass + + N_Channel = 8 + with h5py.File(h5filename,'r') as f: + BT_SIM = f['Sim'][:] + x_data = f['X'][:] + y_data = f['Y'][:] + lat = f['LAT'][:] + lon = f['LON'][:] + + N_X = 2748 + N_Y = 2748 + + N_Profiles = x_data.size + BT_SIM1 = np.reshape(BT_SIM,(N_Profiles,N_Channel)) + BT_SIM_Used = np.full((N_Y,N_X,N_Channel),65535,dtype=np.uintc) + lat_Used = np.full((N_Y,N_X),-9999.9,dtype=np.float32) + lon_Used = np.full((N_Y,N_X),-9999.9,dtype=np.float32) + + for iprofile in range(N_Profiles): + iX = int(x_data[iprofile]) + iY = int(y_data[iprofile]) + BT_SIM_Used[iY-1,iX-1,0:N_Channel] = (BT_SIM1[iprofile,0:N_Channel]*100).astype(np.uintc) + lat_Used[iY-1,iX-1] = lat[iprofile].astype(np.float32) + lon_Used[iY-1,iX-1] = lon[iprofile].astype(np.float32) + + print(iX) + print(BT_SIM_Used.shape) + + with h5py.File(save_file, 'w') as f: + f.create_dataset('BT_SIM', data=BT_SIM_Used) + f.create_dataset('lat',data=lat_Used) + f.create_dataset('lon',data= lon_Used) + + print" >>", save_file, 'saved ! ' + if (os.path.exists(h5filename)): + os.remove(h5filename) + +files1 = sys.argv[1:] #/fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/FY4B/AGRI/GRAPES/2024/20240125/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_20240125200000_4000M_cloudy_profiles.dat +if not files1: # + print( + """ + usage: + python {0} /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/FY4B/AGRI/GRAPES/2024/*/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_202401*_4000M_cloudy_profiles.dat + """.format(__file__)) +else: + import traceback + for k in files1: + hdfmake_agri(k) + diff --git a/AGRI/3_convert_GRAPES_4B_AGRI_hdf.py b/AGRI/3_convert_GRAPES_4B_AGRI_hdf.py new file mode 100644 index 0000000..523b5c6 --- /dev/null +++ b/AGRI/3_convert_GRAPES_4B_AGRI_hdf.py @@ -0,0 +1,36 @@ + +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--agriopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_agri_options.yaml', + help='Path to option YAML file.') + + parser.add_argument('--file','-f', type=str, + required = True, + help='Path to L1 file.') + + args = parser.parse_args() + agriopt = parse(args.agriopt) + + simulate = utils.simbase(args.file,agriopt) + simulate.make_config() + simulate.run_nonrunexe() + + # bg = utils.bgbase(args.file,agriopt) + # bg.del_bgfile() + simulate.del_temp() + simulate.del_bgfile() \ No newline at end of file diff --git a/AGRI/4_make_GRAPES_4B_AGRI_Filter.py b/AGRI/4_make_GRAPES_4B_AGRI_Filter.py new file mode 100644 index 0000000..8c44e61 --- /dev/null +++ b/AGRI/4_make_GRAPES_4B_AGRI_Filter.py @@ -0,0 +1,39 @@ +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +import h5py +def make_filter(geofile,filename): + # bn=os.path.basename(filename) + # filetime= datetime.datetime.strptime(bn,"FY4B-_AGRI--_N_DISK_1047E_L1-_FDI-_MULT_NOM_%Y%m%d%H%M_BT.h5") + with h5py.File(geofile,'r') as f,h5py.File(filename,'a')as ff: + SunGlintAngle = f['/Navigation/NOMSunGlintAngle'][:] + if 'SunGlintAngle' in ff.keys(): + del ff['SunGlintAngle'] + ff.create_dataset('SunGlintAngle',data = SunGlintAngle,dtype='f4',compression=9) + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--agriopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_agri_options.yaml', + help='Path to option YAML file.') + + parser.add_argument('--file','-f', type=str, + required = True, + help='Path to L1 file.') + + args = parser.parse_args() + agriopt = parse(args.agriopt) + simulate = utils.simbase(args.file,agriopt) + + make_filter(args.file,simulate.outfile()) diff --git a/AGRI/run_GRAPES_4B_AGRI.py b/AGRI/run_GRAPES_4B_AGRI.py new file mode 100644 index 0000000..2281d7b --- /dev/null +++ b/AGRI/run_GRAPES_4B_AGRI.py @@ -0,0 +1,40 @@ +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--agriopt','-opt', type=str, + default='../options/FY4B_agri_options.yaml', + help='Path to option YAML file.') + + parser.add_argument('--file','-f', type=str, + required = True, + help='Path to L1 file.') + + + args = parser.parse_args() + agriopt = parse(args.agriopt) + + # ############## backgrounddata ########## + background = utils.bgbase(args.file,agriopt) + if background.match_nwp(): + background.make_config() + background.run() + else: + exit(1) + # ############## simulate ############### + simulate = utils.simbase(args.file,agriopt) + simulate.make_config() + simulate.run() \ No newline at end of file diff --git a/GIIRS/0_combine_GRAPES_4B_GIIRS_2h_data.py b/GIIRS/0_combine_GRAPES_4B_GIIRS_2h_data.py new file mode 100644 index 0000000..98bcec1 --- /dev/null +++ b/GIIRS/0_combine_GRAPES_4B_GIIRS_2h_data.py @@ -0,0 +1,40 @@ +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--reg','-r', type=str, + required = True, + help='regiontype') + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + print(args.time) + print(args.reg) + Giirscomobj = giirscombine.Giirscombine(args.time,args.reg,giirsopt) + Giirscomfile = Giirscomobj.run() diff --git a/GIIRS/0_produce_GRAPES_4B_GIIRS_background_data.py b/GIIRS/0_produce_GRAPES_4B_GIIRS_background_data.py new file mode 100644 index 0000000..fc7a85a --- /dev/null +++ b/GIIRS/0_produce_GRAPES_4B_GIIRS_background_data.py @@ -0,0 +1,52 @@ +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +import argparse +import glob +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine + + +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--reg','-r', type=str, + required = True, + help='regiontype') + + + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + parser.add_argument('--wmtype','-m', type=str, + required = True, + help='wmtype:MW,LW') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + print(args.time) + Giirscomobj = giirscombine.Giirscombine(args.time,args.reg,giirsopt) + Giirscomfile = Giirscomobj.outfile + background = utils.bgbase(Giirscomfile,giirsopt) + if background.match_nwp(): + background.make_config(args.wmtype) + background.run(args.wmtype) + + else: + exit(1) \ No newline at end of file diff --git a/GIIRS/1_make_GRAPES_4B_GIIRS_simulate_config.py b/GIIRS/1_make_GRAPES_4B_GIIRS_simulate_config.py new file mode 100644 index 0000000..788c54f --- /dev/null +++ b/GIIRS/1_make_GRAPES_4B_GIIRS_simulate_config.py @@ -0,0 +1,44 @@ +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--reg','-r', type=str, + required = True, + help='regiontype') + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + parser.add_argument('--wmtype','-m', type=str, + required = True, + help='wmtype:MW,LW') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + print(args.time) + Giirscomobj = giirscombine.Giirscombine(args.time,args.reg,giirsopt) + Giirscomfile = Giirscomobj.outfile + + simulate = utils.simbase(Giirscomfile,giirsopt) + simulate.make_config(args.wmtype) + + \ No newline at end of file diff --git a/GIIRS/3_convert_GRAPES_4B_GIIRS_hdf.py b/GIIRS/3_convert_GRAPES_4B_GIIRS_hdf.py new file mode 100644 index 0000000..affe549 --- /dev/null +++ b/GIIRS/3_convert_GRAPES_4B_GIIRS_hdf.py @@ -0,0 +1,50 @@ +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse + +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--reg','-r', type=str, + required = True, + help='regiontype') + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + parser.add_argument('--wmtype','-m', type=str, + required = True, + help='wmtype:MW,LW') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + print(args.time) + Giirscomobj = giirscombine.Giirscombine(args.time,args.reg,giirsopt) + Giirscomfile = Giirscomobj.outfile + + simulate = utils.simbase(Giirscomfile,giirsopt) + simulate.make_config(args.wmtype) + simulate.run_nonrunexe(args.wmtype) + # bg = utils.bgbase(Giirscomfile,giirsopt) + # bg.del_bgfile(args.wmtype) + simulate.del_temp() + simulate.del_bgfile() + + diff --git a/GIIRS/4_split_GRAPES_4B_GIIRS_simulate_data.py b/GIIRS/4_split_GRAPES_4B_GIIRS_simulate_data.py new file mode 100644 index 0000000..9bac781 --- /dev/null +++ b/GIIRS/4_split_GRAPES_4B_GIIRS_simulate_data.py @@ -0,0 +1,42 @@ +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse + +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--reg','-r', type=str, + required = True, + help='regiontype') + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + print(args.time) + Giirscomobj = giirscombine.Giirscombine(args.time,args.reg,giirsopt) + Giirscomfile = Giirscomobj.outfile + + simulate = utils.simbase(Giirscomfile,giirsopt) + LWcombinfile = simulate.outfile('LW') + MWcombinfile = simulate.outfile('MW') + Giirscomobj.split(MWcombinfile,LWcombinfile) + diff --git a/GIIRS/5_produce_GRAPES_4B_GIIRS_CLM_data.py b/GIIRS/5_produce_GRAPES_4B_GIIRS_CLM_data.py new file mode 100644 index 0000000..5cc8f7e --- /dev/null +++ b/GIIRS/5_produce_GRAPES_4B_GIIRS_CLM_data.py @@ -0,0 +1,126 @@ +# -*- coding:utf-8 -*- +import os +import sys +import datetime +import time +import glob +import numpy as np +import argparse +import h5py +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine + +def make_clmfilter_combine(LWcombinfile,outfile,limit=5): + opath = os.path.dirname(outfile) + if not os.path.exists(opath): + os.makedirs(opath) + #352 900 、368 910 + with h5py.File(LWcombinfile,'r')as f: + lat = f['lat'][:] + nshape =np.shape(lat) + # clm = np.full(nshape,0,dtype='i2') + # print clm.shape + + + # omb900 = f['BT_OBS'][:,:,352]-f['BT_SIM'][:,:,352] + # omb900=omb900/100 + + BT_obs = f['BT_OBS'][:,:,(224,264,312,352,400)]*1.0 + BT_sim = f['BT_SIM'][:,:,(224,264,312,352,400)]*1.0 + idnon=np.argwhere((BT_sim==65535)|(BT_obs==65535)) + BT_obs[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_sim[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_obs=BT_obs*0.01 + BT_sim=BT_sim*0.01 + OMB = BT_obs - BT_sim + idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + # idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + # print idclm + Cld = np.full([OMB.shape[0],OMB.shape[1]],1,dtype='u1') + Cld[idclm[:,0],idclm[:,1]] = 2 + Cld[idnon[:,0],idnon[:,1]] = 0 + + + # clm[(omb900-limit)]=1 + # print(np.argwhere(clm==1)),np.shape(np.argwhere(clm==1)) + with h5py.File(outfile,'w')as f: + f.create_dataset('CLM',data=Cld,dtype='i2',compression=9) + + +def make_clmfilter(LWcombinfile,L1combinfile,outpath,limit=5): + + if not os.path.exists(outpath): + os.makedirs(outpath) + + with h5py.File(L1combinfile,'r') as f,h5py.File(LWcombinfile,'r')as fff: + + BT_obs = fff['BT_OBS'][:,:,(224,264,312,352,400)]*1.0 + BT_sim = fff['BT_SIM'][:,:,(224,264,312,352,400)]*1.0 + idnon=np.argwhere((BT_sim==65535)|(BT_obs==65535)) + BT_obs[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_sim[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_obs=BT_obs*0.01 + BT_sim=BT_sim*0.01 + OMB = BT_obs - BT_sim + idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + + # idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + # print idclm + Cld = np.full([OMB.shape[0],OMB.shape[1]],1,dtype='u1') + Cld[idclm[:,0],idclm[:,1]] = 2 + Cld[idnon[:,0],idnon[:,1]] = 0 + # print f['Filenames'] + pointnum = np.shape(f['Filenames'][:])[2] + for i in range(pointnum): + filepoint = f['Filenames'][0,0,i] + # print filepoint + outfile = outpath+'/FY4B-_GIIRS-_N_REGX_1235E_L1-_IRD-_MULT_NUL_'+filepoint+'CLM.HDF' + print outfile + ff=h5py.File(outfile,'w') + ff.create_dataset('clm',data=Cld[:,i],dtype='u2',compression=9) + ff.close() + + + + +if __name__ == '__main__': + + + + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--reg','-r', type=str, + required = True, + help='regiontype') + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + print(args.time) + Giirscomobj = giirscombine.Giirscombine(args.time,args.reg,giirsopt) + Giirscomfile = Giirscomobj.outfile + + filetime = datetime.datetime.strptime(args.time, '%Y%m%d%H') + simulate = utils.simbase(Giirscomfile,giirsopt) + LWcombinfile = simulate.outfile('LW') + + sigoptpath = filetime.strftime(giirsopt['path']['sigclwpath']) + comoptpath = filetime.strftime(giirsopt['path']['webclwpath']) + + comoptbase = os.path.basename(Giirscomfile)[0:44]+args.time+'_MASK.HDF' + comoptfile = comoptpath+comoptbase + make_clmfilter_combine(LWcombinfile,comoptfile) + make_clmfilter(LWcombinfile,Giirscomfile,sigoptpath) \ No newline at end of file diff --git a/GIIRS/redo_GRAPES_4B_giirs.py b/GIIRS/redo_GRAPES_4B_giirs.py new file mode 100644 index 0000000..b49f7a9 --- /dev/null +++ b/GIIRS/redo_GRAPES_4B_giirs.py @@ -0,0 +1,26 @@ +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np + +if __name__ == '__main__': + time0 = sys.argv[1] + time1 = sys.argv[2] + start = datetime.datetime.strptime(str(time0),'%Y%m%d%H') + end = datetime.datetime.strptime(str(time1),'%Y%m%d%H') + # while start <= end: + # times = datetime.datetime.strftime(start,'%Y%m%d') + # filelist = glob.glob('/fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4B/%s/%s/FY4B-_GIIRS-_N_REGX_1330E_L1-_IRD-_MULT_NUL_%s*_012KM_C01V1.HDF'%(times[0:4],times,times)) + # filelist.sort() + # for i in filelist: + # os.system('python /fy4_ads_data/stss_v2.0/workflow/Base/GIIRS/run_GRAPES_4B_giirs.py -f %s -m MW'%(i)) + # start+=datetime.timedelta(days=1) + + while start <= end: + times = datetime.datetime.strftime(start,'%Y%m%d%H') + + os.system('python /fy4_ads_data/stss_v2.0/workflow/Base/GIIRS/run_GRAPES_4B_giirs.py -t %s -m LW'%(times)) + start+=datetime.timedelta(hours=2) \ No newline at end of file diff --git a/GIIRS/run_GRAPES_4B_giirs.py b/GIIRS/run_GRAPES_4B_giirs.py new file mode 100644 index 0000000..9a20b38 --- /dev/null +++ b/GIIRS/run_GRAPES_4B_giirs.py @@ -0,0 +1,143 @@ +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +import argparse +import h5py +parentdir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) +sys.path.insert(0,parentdir) +import utils +from options import parse +import giirscombine_test + + +def make_clmfilter_combine(LWcombinfile,outfile,limit=5): + opath = os.path.dirname(outfile) + if not os.path.exists(opath): + os.makedirs(opath) + with h5py.File(LWcombinfile,'r')as f: + lat = f['lat'][:] + nshape =np.shape(lat) + # clm = np.full(nshape,0,dtype='i2') + # print clm.shape + + + # omb900 = f['BT_OBS'][:,:,352]-f['BT_SIM'][:,:,352] + # omb900=omb900/100 + + BT_obs = f['BT_OBS'][:,:,(224,264,312,352,400)]*1.0 + BT_sim = f['BT_SIM'][:,:,(224,264,312,352,400)]*1.0 + idnon=np.argwhere((BT_sim==65535)|(BT_obs==65535)) + BT_obs[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_sim[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_obs=BT_obs*0.01 + BT_sim=BT_sim*0.01 + OMB = BT_obs - BT_sim + idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + # idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + # print idclm + Cld = np.full([OMB.shape[0],OMB.shape[1]],1,dtype='u1') + Cld[idclm[:,0],idclm[:,1]] = 2 + Cld[idnon[:,0],idnon[:,1]] = 0 + + + # clm[(omb900-limit)]=1 + # print(np.argwhere(clm==1)),np.shape(np.argwhere(clm==1)) + with h5py.File(outfile,'w')as f: + f.create_dataset('CLM',data=Cld,dtype='i2',compression=9) + + +def make_clmfilter(LWcombinfile,L1combinfile,outpath,limit=5): + + if not os.path.exists(outpath): + os.makedirs(outpath) + + with h5py.File(L1combinfile,'r') as f,h5py.File(LWcombinfile,'r')as fff: + + BT_obs = fff['BT_OBS'][:,:,(224,264,312,352,400)]*1.0 + BT_sim = fff['BT_SIM'][:,:,(224,264,312,352,400)]*1.0 + idnon=np.argwhere((BT_sim==65535)|(BT_obs==65535)) + BT_obs[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_sim[idnon[:,0],idnon[:,1],idnon[:,2]] = np.nan + BT_obs=BT_obs*0.01 + BT_sim=BT_sim*0.01 + OMB = BT_obs - BT_sim + idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + + # idclm = np.argwhere((OMB<=-5)|(OMB>=5)|(BT_obs<=260)) + # print idclm + Cld = np.full([OMB.shape[0],OMB.shape[1]],1,dtype='u1') + Cld[idclm[:,0],idclm[:,1]] = 2 + Cld[idnon[:,0],idnon[:,1]] = 0 + # print f['Filenames'] + basename = os.path.basename(L1combinfile) + pointnum = np.shape(f['Filenames'][:])[2] + for i in range(pointnum): + filepoint = f['Filenames'][0,0,i] + # print filepoint + outfile = outpath+'/'+basename[0:44]+filepoint+'CLM.HDF' + print outfile + ff=h5py.File(outfile,'w') + ff.create_dataset('clm',data=Cld[:,i],dtype='u2',compression=9) + ff.close() + + +if __name__ == '__main__': + + + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='/fy4_ads_data/stss_v2.0/workflow/Base/options/FY4B_giirs_options_test.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + #'2022041300' + parser.add_argument('--time','-t', type=str, + required = True, + help='time.YYYYMMDDHH.') + + parser.add_argument('--wmtype','-m', type=str, + required = True, + help='wmtype:MW,LW') + + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + + + + # print(args.time) + Giirscomobj = giirscombine_test.Giirscombine(args.time,giirsopt) + Giirscomfile = Giirscomobj.run() + Giirscomfile = Giirscomobj.outfile + # Giirscomfile = args.file + print(Giirscomfile) + background = utils.bgbase(Giirscomfile,giirsopt) + if background.match_nwp(): + # background.make_config('LW') + # background.run("LW") + background.make_config(args.wmtype) + background.run(args.wmtype) + + # # Giirscomfile = args.file + simulate = utils.simbase(Giirscomfile,giirsopt) + simulate.make_config(args.wmtype) + simulate.run(args.wmtype) + + filetime = datetime.datetime.strptime(args.time, '%Y%m%d%H') + # simulate = utils.simbase(Giirscomfile,giirsopt) + LWcombinfile = simulate.outfile('LW') + + sigoptpath = filetime.strftime(giirsopt['path']['sigclwpath']) + comoptpath = filetime.strftime(giirsopt['path']['webclwpath']) + + comoptbase = os.path.basename(Giirscomfile)[0:44]+args.time+'_MASK.HDF' + comoptfile = comoptpath+comoptbase + make_clmfilter_combine(LWcombinfile,comoptfile) + make_clmfilter(LWcombinfile,Giirscomfile,sigoptpath) + diff --git a/GRAPES.py b/GRAPES.py new file mode 100644 index 0000000..c0a3709 --- /dev/null +++ b/GRAPES.py @@ -0,0 +1,104 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Feb 23 17:43:31 2023 + +@author: 11747 +""" + + +import os +import sys +import datetime +import time +import glob +from datetime import timedelta +import math +NWPPATH ='/NWPDATA/GRAPES/' +NWPNAME = 'gmf.gra.{:10s}{:03d}.grb2' +UPGRADEDATA = '202305230001' +class GRAPESMETA: + + def __init__(self,nwppath=NWPPATH,nwpname=NWPNAME,add='%Y/%m/'): + + self._nwptype = 'GRAPES' + self._nwppath = nwppath + self._nwpname = nwpname + self._add = add + self._resolution = 0.25 + @property + def resolution(self): + return self._resolution + + def match(self,sattime,nums=3,delttime=10800,delayed=0,fcschoice=12,fcssame = True): + + sattimest=datetime.datetime.strptime(sattime,'%Y%m%d%H%M') + if sattimest>datetime.datetime.strptime(UPGRADEDATA,'%Y%m%d%H%M'): + self._resolution = 0.125 + + satdayc=datetime.datetime(sattimest.year,sattimest.month,sattimest.day) + + # if delayed 1: + for i in range(1,nums): + fcsthours=fcsthours+int(delttime/3600) + if not fcssame: + if fcsthours > delayed +fcschoice: + nwptfcstimest+=datetime.timedelta(hours=fcschoice) + fcsthours-=fcschoice + nwptfcstime=datetime.datetime.strftime(nwptfcstimest,'%Y%m%d%H') + nwpfpath = datetime.datetime.strftime(nwptfcstimest,nwppath) + nwpfile1 = nwpfpath+ NWPNAME.format(nwptfcstime,fcsthours) + nwpt1 = nwptfcstimest+datetime.timedelta(hours=fcsthours) + nwptime1 = datetime.datetime.strftime(nwpt1, '%Y%m%d%H') + '00' + nwptstr.append(nwptime1) + nwptime.append(nwpt1) + nwp1file.append(nwpfile1) + nwp2file.append(None) + return nwp1file+nwp2file,nwptstr,nwptime + + +if __name__ == '__main__': + A = GRAPESMETA() + print(A.resolution) + print(A.match('202305230015',nums=3,delttime=10800,delayed=0,fcschoice=12,fcssame = True)) + print(A.match('202305230015',nums=3,delttime=10800,delayed=6,fcschoice=12,fcssame = True)) + print(A.match('202305230500',nums=3,delttime=10800,delayed=15,fcschoice=12,fcssame = True)) + print(A.match('202305230500',nums=3,delttime=10800,delayed=6,fcschoice=12,fcssame = True)) + print(A.match('202305230500',nums=3,delttime=10800,delayed=3,fcschoice=12,fcssame = True)) + print(A.resolution) +# class NWP: + +# def __init__(self): + +# self = obj + +# def match(self,obj,num1=1): +# obj.match() + + +# era5 = ERA5META() + +# (nwppth,nwptime) = nwp.match(era5,num=3) + + + + diff --git a/giirscombine/__init__.py b/giirscombine/__init__.py new file mode 100644 index 0000000..a12d5a0 --- /dev/null +++ b/giirscombine/__init__.py @@ -0,0 +1,330 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Apr 14 18:43:46 2022 + +@author: zhangqiankun +""" + +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +from datetime import timedelta +import datetime +import h5py +parentdir = os.path.dirname(os.path.abspath(__file__)) +sys.path.insert(0,parentdir) +# print sys.path +import utils + +class dataset(object): + """ + Decorator that converts a method with a single self argument into a + property cached on the instance. + Optional ``name`` argument allows you to make cached dataset of other + methods. (e.g. url = dataset(get_absolute_url, name='url') ) + """ + + def __init__(self, func, name=None): + self.func = func + self.__doc__ = getattr(func, '__doc__') + self.name = name or func.__name__ + + def __get__(self, instance, cls=None): + if instance is None: + return self + res = instance.__dict__[self.name] = self.func(instance) + return res + + +class Girrsbase(utils.satfilebase): + def __new__(cls,filename): + # self = object.__new__(cls) + self = super(Girrsbase,cls).__new__(cls,filename) + self.f_obj = h5py.File(filename, 'r') + attr=self.f_obj.attrs + if ('Observing Beginning Date' in attr.keys()) and ('Observing Beginning Time' in attr.keys()): + date=attr['Observing Beginning Date'] + time=attr['Observing Beginning Time'] + if len(date)>=8 and len(time)>=8: + self.obstime = numpy.array(date+'T'+time,'M8').astype('M8[s]').astype('f8') + else: + self.obstime=(datetime.datetime.strptime(self.startime,'%Y%m%d%H%M%S')-datetime.datetime(1970,1,1)).total_seconds() + else: + self.obstime=(datetime.datetime.strptime(self.startime,'%Y%m%d%H%M%S')-datetime.datetime(1970,1,1)).total_seconds() + return self + # if self._satname=='FY4B': + @dataset + def lw_lat(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Latitude_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRLW_Latitude'][()] + + @dataset + def lw_lon(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Longitude_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRLW_Longitude'][()] + + @dataset + def mw_lat(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Latitude_MW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRMW_Latitude'][()] + + @dataset + def mw_lon(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Longitude_MW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRMW_Longitude'][()] + + @dataset + def mw_wm(self): + if self._satname=='FY4B': + return self.f_obj['/Data/WN_MW'][2:-2] + elif self._satname=='FY4A': + # return self.f_obj['IRMW_VaildWaveLength'][()] + return self.f_obj['WV_MW'][()] + @dataset + def lw_wm(self): + if self._satname=='FY4B': + return self.f_obj['/Data/WN_LW'][2:-2] + elif self._satname=='FY4A': + # return self.f_obj['IRLW_VaildWaveLength'][()] + return self.f_obj['WV_LW'][()] + @dataset + def mw_rad(self): + if self._satname=='FY4B': + return self.f_obj['/Data/ES_RealMW'][2:-2,:] + elif self._satname=='FY4A': + return self.f_obj['ES_RealMW'][()] + + @dataset + def lw_rad(self): + if self._satname=='FY4B': + return self.f_obj['/Data/ES_RealLW'][2:-2,:] + elif self._satname=='FY4A': + return self.f_obj['ES_RealLW'][()] +####4B + @dataset + def lw_solzenith(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Solar_Zenith_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRLW_SolarZenith'][()] + @dataset + def lw_solazimuth(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Solar_Azimuth_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRLW_SolarAzimuth'][()] + @dataset + def lw_senazimuth(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Sensor_Azimuth_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRLW_SatelliteAzimuth'][()] + @dataset + def lw_senzenith(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Sensor_Zenith_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRLW_SatelliteZenith'][()] + + @dataset + def mw_solzenith(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Solar_Zenith_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRMW_SolarZenith'][()] + @dataset + def mw_solazimuth(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Solar_Azimuth_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRMW_SolarAzimuth'][()] + @dataset + def mw_senazimuth(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Sensor_Azimuth_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRMW_SatelliteAzimuth'][()] + @dataset + def mw_senzenith(self): + if self._satname=='FY4B': + return self.f_obj['/Geolocation/Sensor_Zenith_LW'][()] + elif self._satname=='FY4A': + return self.f_obj['IRMW_SatelliteZenith'][()] + @dataset + def lw_QA(self): + if self._satname=='FY4B': + return self.f_obj['/QA/QA_LW'][()] + @dataset + def mw_QA(self): + if self._satname=='FY4B': + return self.f_obj['/QA/QA_MW'][()] + + def close(self): + self.f_obj.close() + + + +class Giirscombine(object): + def __init__(self,startime,regopt,options): + # self._datetime1=datetime.datetime.strptime(str(times),'%Y%m%d%H') + stdatatime = datetime.datetime.strptime(str(startime),'%Y%m%d%H') + self._startime = stdatatime.strftime('%Y%m%d%H%M%S') + + self._satname = options['satname'] + self._cominterval = options['combine']['cominterval'] + # print options['combine']['satpath']+'%s/%s/%s/'%(regopt,self._startime[0:4],self._startime[0:8]) + + self._satpath = options['combine']['satpath']+'%s/%s/%s/'%(regopt,self._startime[0:4],self._startime[0:8]) + self._outpath = stdatatime.strftime(options['combine']['compath']) + print(self._satpath) + endatatime = stdatatime+datetime.timedelta(hours=self._cominterval) + self._endtime = endatatime.strftime('%Y%m%d%H%M%S') + self._filenamelist=[] + for i in range(self._cominterval): + dedatetime=datetime.datetime.strptime(str(startime),'%Y%m%d%H')+datetime.timedelta(hours=i) + detime = dedatetime.strftime('%Y%m%d%H') + self._filenamelist += glob.glob(self._satpath+'/'+'*_'+detime+'*') + self._filenamelist.sort() + giirsobject = Girrsbase((self._filenamelist[0])) + self._outfile = self._outpath +'%s%s_%s_%s_%s'%(giirsobject.basename[0:44], + self._startime,self._endtime,giirsobject._resolution,'C01V1.HDF') + self._splitpath = stdatatime.strftime(options['split']['splitpath']) + def run(self): + + if len(self._filenamelist)>0: + if not os.path.exists(self._outpath): + os.makedirs(self._outpath) + # giirsobject = Girrsbase((self._filenamelist[0])) + # self._outfile = self._outpath +'%s%s_%s_%s_%s'%(giirsobject.basename[0:44], + # self._startime,self._endtime,giirsobject._resolution,'C01V1.HDF') + + for i,filename in enumerate(self._filenamelist): + giirsobject = Girrsbase(filename) + timestamp0 = giirsobject.obstime + # timestamp0=( + # datetime.datetime.strptime(giirsobject.startime,'%Y%m%d%H%M%S')- + # datetime.datetime(1970,1,1) + # ).total_seconds()+308/26*(int(giirsobject.vesion[:3])-1)#秒 + timestamp=np.tile(timestamp0,128).astype('f8') + files0=giirsobject.startime+'_'+giirsobject.vesion + idqa = giirsobject.lw_QA[:,-1]<80 + giirsobject.lw_lat[idqa] = -9999 + giirsobject.lw_lon[idqa] = -9999 + giirsobject.lw_rad[...,idqa] = -9999 + + idqa = giirsobject.mw_QA[:,-1]<80 + giirsobject.mw_lat[idqa] = -9999 + giirsobject.mw_lon[idqa] = -9999 + giirsobject.mw_rad[...,idqa] = -9999 + + if i == 0: + latitude_combine_LW = giirsobject.lw_lat + longitude_combine_LW = giirsobject.lw_lon + senzenith_combine_LW = giirsobject.lw_senzenith + solzenith_combine_LW = giirsobject.lw_solzenith + senazimuth_combine_LW = giirsobject.lw_senazimuth + solazimuth_combine_LW = giirsobject.lw_solazimuth + BT_obs_combine_LW = giirsobject.lw_rad + latitude_combine_MW = giirsobject.mw_lat + longitude_combine_MW = giirsobject.mw_lon + senzenith_combine_MW = giirsobject.mw_senzenith + solzenith_combine_MW = giirsobject.mw_solzenith + senazimuth_combine_MW = giirsobject.mw_senazimuth + solazimuth_combine_MW = giirsobject.mw_solazimuth + BT_obs_combine_MW = giirsobject.mw_rad + timestamp_combine = timestamp + waven_LW = giirsobject.lw_wm + waven_MW = giirsobject.mw_wm + files_combine = files0 + else: + latitude_combine_LW = np.dstack((latitude_combine_LW,giirsobject.lw_lat)) + longitude_combine_LW = np.dstack((longitude_combine_LW,giirsobject.lw_lon)) + senzenith_combine_LW = np.dstack((senzenith_combine_LW,giirsobject.lw_senzenith)) + solzenith_combine_LW = np.dstack((solzenith_combine_LW,giirsobject.lw_solzenith)) + senazimuth_combine_LW = np.dstack((senazimuth_combine_LW,giirsobject.lw_senazimuth)) + solazimuth_combine_LW = np.dstack((solazimuth_combine_LW,giirsobject.lw_solazimuth)) + BT_obs_combine_LW = np.dstack((BT_obs_combine_LW,giirsobject.lw_rad)) + latitude_combine_MW = np.dstack((latitude_combine_MW,giirsobject.mw_lat)) + longitude_combine_MW = np.dstack((longitude_combine_MW,giirsobject.mw_lon)) + senzenith_combine_MW = np.dstack((senzenith_combine_MW,giirsobject.mw_senzenith)) + solzenith_combine_MW = np.dstack((solzenith_combine_MW,giirsobject.mw_solzenith)) + senazimuth_combine_MW = np.dstack((senazimuth_combine_MW,giirsobject.mw_senazimuth)) + solazimuth_combine_MW = np.dstack((solazimuth_combine_MW,giirsobject.mw_solazimuth)) + BT_obs_combine_MW = np.dstack((BT_obs_combine_MW,giirsobject.mw_rad)) + timestamp_combine = np.dstack((timestamp_combine,timestamp)) + files_combine = np.dstack((files_combine,files0)) + giirsobject.close() + + with h5py.File(self._outfile,'w')as ff: + ff.create_dataset('IRLW_Latitude',data=latitude_combine_LW) + ff.create_dataset('IRLW_Longitude',data=longitude_combine_LW) + ff.create_dataset('IRLW_SatelliteZenith',data=senzenith_combine_LW) + ff.create_dataset('IRLW_SolarZenith',data=solzenith_combine_LW) + ff.create_dataset('IRLW_SatelliteAzimuth',data=senazimuth_combine_LW) + ff.create_dataset('IRLW_SolarAzimuth',data=solazimuth_combine_LW) + ff.create_dataset('ES_RealLW',data=BT_obs_combine_LW) + ff.create_dataset('IRLW_VaildWaveLength',data=waven_LW) + + ff.create_dataset('IRMW_Latitude',data=latitude_combine_MW) + ff.create_dataset('IRMW_Longitude',data=longitude_combine_MW) + ff.create_dataset('IRMW_SatelliteZenith',data=senzenith_combine_MW) + ff.create_dataset('IRMW_SolarZenith',data=solzenith_combine_MW) + ff.create_dataset('IRMW_SatelliteAzimuth',data=senazimuth_combine_MW) + ff.create_dataset('IRMW_SolarAzimuth',data=solazimuth_combine_MW) + ff.create_dataset('ES_RealMW',data=BT_obs_combine_MW) + ff.create_dataset('IRMW_VaildWaveLength',data=waven_MW) + ff.create_dataset('TimeStamp',data=timestamp_combine) + ff.create_dataset('Filenames', data=files_combine) + print self._outfile + # with h5py.File('/fy4_ads_data/TEST.h5','w') as f: + # f['BT_obs_combine_LW'] = BT_obs_combine_LW[96] + # f['BT_obs_combine_MW'] = BT_obs_combine_LW[96] + + return self._outfile + else: + print('satfile is not exists') + return None + @property + def outfile(self): + return self._outfile + + def split(self,mwfile,lwfile): + with h5py.File(self._outfile,'r') as f , h5py.File(mwfile,'r') as MW, h5py.File(lwfile,'r')as LW: + # print f['Filenames'] + pointnum = np.shape(f['Filenames'][:])[2] + for i in range(pointnum): + filepoint = f['Filenames'][0,0,i] + print filepoint + if not os.path.exists(self._splitpath): + os.makedirs(self._splitpath) + outfile = self._splitpath+'/'+os.path.basename(self._outfile)[0:44]+filepoint+'.HDF' + print outfile + ff=h5py.File(outfile,'w') + ff.create_dataset('ES_RealMW',data=MW['BT_OBS'][:,i,:],dtype='u2',compression=9) + ff.create_dataset('ES_RealLW',data=LW['BT_OBS'][:,i,:],dtype='u2',compression=9) + ff.create_dataset('ES_SimLW',data=LW['BT_SIM'][:,i,:],dtype='u2',compression=9) + ff.create_dataset('ES_SimMW',data=MW['BT_SIM'][:,i,:],dtype='u2',compression=9) + ff.create_dataset('IRLW_LandSeaMask',data=LW['LandSeaMask'][:,i],dtype='u2',compression=9) + ff.create_dataset('IRMW_LandSeaMask',data=MW['LandSeaMask'][:,i],dtype='u2',compression=9) + for j in f.keys(): + if j not in['IRMW_VaildWaveLength','IRLW_VaildWaveLength','Filenames','ES_RealMW','ES_RealLW']: + data=f[j][:,:,i] + ff.create_dataset(j,data=data,dtype=data.dtype,compression=9) + elif j in ['IRMW_VaildWaveLength','IRLW_VaildWaveLength']: + data=f[j][:] + ff.create_dataset(j,data=data,dtype=data.dtype,compression=9) + ff.close() + + diff --git a/giirscombine/__init__.pyc b/giirscombine/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2fcc1664c420a2d70cf816e5ba181e8ae6cc1ba8 GIT binary patch literal 14012 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 literal 0 HcmV?d00001 diff --git a/main.py b/main.py new file mode 100644 index 0000000..dac783c --- /dev/null +++ b/main.py @@ -0,0 +1,69 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Feb 18 17:36:03 2022 + +@author: zhangqiankun +""" + +import argparse +import glob +import utils +from options import parse +import giirscombine +if __name__ == '__main__': + + + parser = argparse.ArgumentParser() + + parser.add_argument('--giirsopt','-opt', type=str, + default='./options/FY4B_girrs_options.yaml', + help='Path to option YAML file.') + + # parser.add_argument('--file','-f', type=str, + # required = True, + # help='Path to L1 file.') + + parser.add_argument('--agriopt','-Aopt', type=str, + default='./options/FY4B_AGRI_options.yaml', + help='Path to option YAML file.') + args = parser.parse_args() + giirsopt = parse(args.giirsopt) + + # Giirscomobj = giirscombine.Giirscombine('2022041300',giirsopt) + # Giirscomfile = Giirscomobj.run() + + Giirscomfile = '/fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4B/2022/20220413/'+\ + 'FY4B-_GIIRS-_N_REGX_1330E_L1-_IRD-_MULT_NUL_20220413000000_20220413020000_012KM_C01V1.HDF' + # # Giirscomfile = '/fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4A/2021/20210504/'+\ + # # 'FY4A-_GIIRS-_N_REGX_1047E_L1-_IRD-_MULT_NUL_20210504000000_20210504020000_016KM_C01V1.HDF' + background = utils.bgbase(Giirscomfile,giirsopt) + if background.match_nwp(): + # print('W') + # background.make_config() + # background.run('LW') + background.make_config() + background.run('MW') + + + + # args = parser.parse_args() + # agriopt = parse(args.agriopt) + + # satfile = '/FY4B_DATA/AGRI/L1/FDI/DISK/GEO/2022/20220415/'+\ + # 'FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_20220415031500_20220415032959_4000M_V0001.HDF' + # # Giirscomfile = '/fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4A/2021/20210504/'+\ + # # 'FY4A-_GIIRS-_N_REGX_1047E_L1-_IRD-_MULT_NUL_20210504000000_20210504020000_016KM_C01V1.HDF' + # background = utils.bgbase(satfile,agriopt) + # print background.instrument + # print(background.match_nwp()) + # if background.match_nwp(): + # # + # # background.make_config() + + # background.make_config() + # background.run() + # # background.del_config() + # simopt = parse(args.simopt) + # simulate = utils.simbase(args.file,simopt) + # simulate.make_config() + # simulate.run() \ No newline at end of file diff --git a/options/FY4A_giirs_options.yaml b/options/FY4A_giirs_options.yaml new file mode 100644 index 0000000..0f3640a --- /dev/null +++ b/options/FY4A_giirs_options.yaml @@ -0,0 +1,22 @@ +#### general settings +satname: FY4A + +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef/rtcoef_fy4_1_giirs.H5 + +settings: + NWP: GRAPES + NWP_resolution: 0.25 + +combine: + cominterval: 2 # 合成hours(整数) + satpath: /fy4_ads_data/data/FY4A_SIMU/2022/%Y%m%d/ + compath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4A/%Y/%Y%m%d/ + +path: + bgpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + outpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + NWPpath: /NWPDATA/GRAPES/ \ No newline at end of file diff --git a/options/FY4B_agri_options.yaml b/options/FY4B_agri_options.yaml new file mode 100644 index 0000000..89409a8 --- /dev/null +++ b/options/FY4B_agri_options.yaml @@ -0,0 +1,25 @@ +#### general settings +satname: FY4B + +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef_v2.0/rtcoef_fy4_2_agri_v1.dat + emispath: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV12/emis_data/ + simexe: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV_fwd_clr.exe + bgexe: + +settings: + NWP: GRAPES + NWP_resolution: 0.125 + NWP_level: 40 + channels: 8 + numexe: 16 + +path: + bgworkpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + bgoutpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + temppath: /fy4_ads_data/stss_v2.0/Simulator/temp/ #(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + simpath: /fy4_ads_data/data/ + NWPpath: /NWPDATA/GRAPES/ \ No newline at end of file diff --git a/options/FY4B_ghi_options.yaml b/options/FY4B_ghi_options.yaml new file mode 100644 index 0000000..89409a8 --- /dev/null +++ b/options/FY4B_ghi_options.yaml @@ -0,0 +1,25 @@ +#### general settings +satname: FY4B + +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef_v2.0/rtcoef_fy4_2_agri_v1.dat + emispath: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV12/emis_data/ + simexe: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV_fwd_clr.exe + bgexe: + +settings: + NWP: GRAPES + NWP_resolution: 0.125 + NWP_level: 40 + channels: 8 + numexe: 16 + +path: + bgworkpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + bgoutpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + temppath: /fy4_ads_data/stss_v2.0/Simulator/temp/ #(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + simpath: /fy4_ads_data/data/ + NWPpath: /NWPDATA/GRAPES/ \ No newline at end of file diff --git a/options/FY4B_giirs_options.yaml b/options/FY4B_giirs_options.yaml new file mode 100644 index 0000000..72c401b --- /dev/null +++ b/options/FY4B_giirs_options.yaml @@ -0,0 +1,45 @@ +#### general settings +satname: FY4B + +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef_v2.0/rtcoef_fy4_2_giirs_HAMMING_v1.H5 + emispath: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV12/emis_data/ + simexe: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV_fwd_clr.exe + bgexepath: + LW: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/produce_background_data_GRAPES_4B_GIIRS_LW.exe + MW: /fy4_ads_data/stss_v2.0/ProduceBackgroundData_demo/produce_background_data_GRAPES_4B_GIIRS_MW.exe + +settings: + NWP: GRAPES + NWP_resolution: 0.125 + NWP_level: 40 + channels: + LW: 721 + MW: 961 + channelbegin: + LW: 1 + MW: 722 + numexe: 16 + +combine: + cominterval: 1 # 合成hours(整数) + satpath: /FY4B_DATA/GIIRS/L1/IRDO/ + compath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4B/%Y/%Y%m%d/ + +split: + LWsim: + MWsim: + splitpath: /fy4_ads_data/data/FY4B/GIIRS/GRAPES/convert/%Y/%Y%m%d/ + + +path: + bgworkpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + bgoutpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + temppath: /fy4_ads_data/stss_v2.0/Simulator/temp/ #(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + simpath: /fy4_ads_data/data/ #default (self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + NWPpath: /NWPDATA/GRAPES/ + sigclwpath: /fy4_ads_data/data/FY4B/MASK/GIIRS/SigleFile/%Y/%Y%m%d/ + webclwpath: /fy4_ads_data/data/FY4B/MASK/GIIRS/Combine2H/%Y/%Y%m%d/ \ No newline at end of file diff --git a/options/FY4B_giirs_options_1.yaml b/options/FY4B_giirs_options_1.yaml new file mode 100644 index 0000000..a3b2167 --- /dev/null +++ b/options/FY4B_giirs_options_1.yaml @@ -0,0 +1,40 @@ +#### general settings +satname: FY4B + +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef_v2.0/rtcoef_fy4_2_giirs_HAMMING_v1.H5 + emispath: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV12/emis_data/ + simexe: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV_fwd_clr.exe + bgexe: + +settings: + NWP: GRAPES + NWP_resolution: 0.25 + NWP_level: 40 + channels: + LW: 721 + MW: 961 + numexe: 16 + +combine: + cominterval: 2 # 合成hours(整数) + satpath: /FY4B_DATA/GIIRS/L1/IRD/%Y/%Y%m%d/ + compath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4B/%Y/%Y%m%d/ + +split: + LWsim: + MWsim: + splitpath: /fy4_ads_data/data/FY4B/GIIRS/GRAPES/convert/%Y/%Y%m%d/ + + +path: + bgworkpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + bgoutpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + temppath: /fy4_ads_data/stss_v2.0/Simulator/temp/ #(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + simpath: /fy4_ads_data/data/ #default (self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + NWPpath: /NWPDATA/GRAPES/ + sigclwpath: /fy4_ads_data/data/FY4B/MASK/GIIRS/SigleFile/%Y/%Y%m%d/ + webclwpath: /fy4_ads_data/data/FY4B/MASK/GIIRS/Combine2H/%Y/%Y%m%d/ \ No newline at end of file diff --git a/options/FY4B_giirs_options_test.yaml b/options/FY4B_giirs_options_test.yaml new file mode 100644 index 0000000..26350dd --- /dev/null +++ b/options/FY4B_giirs_options_test.yaml @@ -0,0 +1,45 @@ +#### general settings +satname: FY4B + +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef_v2.0/rtcoef_fy4_2_giirs_HAMMING_v1.H5 + emispath: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV12/emis_data/ + simexe: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV_fwd_clr.exe + bgexepath: + LW: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/produce_background_data_GRAPES_4B_GIIRS_LW.exe + MW: /fy4_ads_data/stss_v2.0/ProduceBackgroundData_demo/produce_background_data_GRAPES_4B_GIIRS_MW.exe + +settings: + NWP: GRAPES + NWP_resolution: 0.25 + NWP_level: 40 + channels: + LW: 721 + MW: 961 + channelbegin: + LW: 1 + MW: 722 + numexe: 16 + +combine: + cominterval: 2 # 合成hours(整数) + satpath: /fy4_ads_data/FY4B/data/GIIRS/L1LEE/%Y%m%d_0427/ + compath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/test2/FY4B/%Y/%Y%m%d/ + +split: + LWsim: + MWsim: + splitpath: /fy4_ads_data/data/FY4B/GIIRS/GRAPES/convert/%Y/%Y%m%d/ + + +path: + bgworkpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + bgoutpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + temppath: /fy4_ads_data/stss_v2.0/Simulator/temp/ #(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + simpath: /fy4_ads_data/data/test/ #default (self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + NWPpath: /NWPDATA/GRAPES/ + sigclwpath: /fy4_ads_data/data/FY4B/MASK/GIIRS/SigleFile/test2/%Y/%Y%m%d/ + webclwpath: /fy4_ads_data/data/FY4B/MASK/GIIRS/Combine2H/test2/%Y/%Y%m%d/ \ No newline at end of file diff --git a/options/__init__.py b/options/__init__.py new file mode 100644 index 0000000..e8d2638 --- /dev/null +++ b/options/__init__.py @@ -0,0 +1,29 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Feb 17 10:36:03 2022 + +@author: zhangqiankun +""" + + +import os +from collections import OrderedDict +import yaml +from yaml import resolver +try: + from yaml import CLoader as Loader, CDumper as Dumper +except ImportError: + from yaml import Loader, Dumper + + +def parse(opt_path): + with open(opt_path,mode='r')as f: + opt = yaml.load(f,Loader=Loader) + + # print opt['satname'] + + # for hase, dataset in opt['path'].items(): + # print hase,dataset + # opt['path'] + return opt + diff --git a/options/__init__.pyc b/options/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..bfb68edcfe51a5a2f9fcb8f6aaa06a7918270d2d GIT binary patch literal 823 zcmb_a!EVz)5S@*kIB{EqinxRxd?TkiO)F5N3RR>aA)z7+QY&9pTYE!HY_HkfvH*u-d`Nv)^P%*iYD3xvw(Pr9+od{?22gb&?E$-}pMoz#n1`Uh0b@?3<7k1S z^&G8caG3}215Ip^gAao)89PA;Ct3=wd1ol7nAvm&$WB;BH=QRTJNgBH;Ogvnba zkhqS|7FBa!>|k+Iqi|iyNZ!LmViR2E2*CoZ?&tZPvAaFEWndY6Zo$e8)_Q>X+ZJ5l z=-*$isA(S$o?F676XaRt@L+67Bdl`bgJ?3zR-EV)pP<&Cg2r!d8vTxx(D zI55W;#na^x7rEiNup&0r7=At4AI3LI&!?rjiC+pMW0WdXZDP)gy0Dz@H%m)DP9wCD zk1#Ma31E-elVGrok((Olxym@VG*V^U>@!uCGIL@Hok)5F)M7#`*Fi!~6OwmF-c*g! r_LbI3Cl4_BuYv#3MHdxMaL$WTzMvk=E<(rKW)B%HkM-FO>wA9zr^lwZ literal 0 HcmV?d00001 diff --git a/options/background_options.yaml b/options/background_options.yaml new file mode 100644 index 0000000..5cf963e --- /dev/null +++ b/options/background_options.yaml @@ -0,0 +1,21 @@ +#### general settings +staticfile: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landsea_mask_0.125.nc + elefile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/sdat_elevation_0.05.nc + coeffile: + FY4A_GIIRS: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef/rtcoef_fy4_1_giirs.H5 + FY4B_GIIRS: /fy4_ads_data/stss_v2.0/Simulator/EXE/coef/rtcoef_fy3_5_mwts3_cmbwucq.dat + + + emispath: /fy4_ads_data/stss_v2.0/Simulator/EXE/RTTOV12/emis_data/ + +settings: + NWP: GRAPES + NWP_resolution: 0.25 + +path: + clmpath: + bgpath : /fy4_ads_data/stss_v2.0/ProduceBackgroundData/ + configpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/config/ + outpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/output/ + NWPpath: /NWPDATA/GRAPES/ \ No newline at end of file diff --git a/options/girrscombine_options.yaml b/options/girrscombine_options.yaml new file mode 100644 index 0000000..3b06a63 --- /dev/null +++ b/options/girrscombine_options.yaml @@ -0,0 +1,11 @@ +#### general settings + +settings: + satname: FY4A + cominterval: + hour: 2 #整数 + # NWP_resolution: 0.25 + +path: + satpath: /fy4_ads_data/data/FY4A_SIMU/2022/%Y%m%d/ + outpath: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/combined_GIIRS/FY4A/%Y/%Y%m%d/ \ No newline at end of file diff --git a/options/spec_verify_options.yaml b/options/spec_verify_options.yaml new file mode 100644 index 0000000..8ddbf63 --- /dev/null +++ b/options/spec_verify_options.yaml @@ -0,0 +1,16 @@ +#### general settings +satname: FY4A +instrument: GIIRS +startime: 20220211 + + +#### redis +redis: + host: 10.25.10.14 + port: 6379 + db: 0 + +#### path +path: + lsmfile: /fy4_ads_data/stss_v2.0/ProduceBackgroundData/instrument_geo/landseamask_0.25.nc + clmfile: /fy4_ads_data/data/FY4B/MASK/GIIRS/SigleFile/ \ No newline at end of file diff --git a/utils.py b/utils.py new file mode 100644 index 0000000..7b69b84 --- /dev/null +++ b/utils.py @@ -0,0 +1,722 @@ +# -*- coding: utf-8 -*- +""" +Created on Thu Feb 28 15:16:57 2022 + +@author: zhangqiankun +""" + +import os +import sys +import numpy as numpy +import datetime +import time +import glob +import numpy as np +from datetime import timedelta +import datetime +import h5py +import GRAPES + + + +# def match_NWP(sattime, nwppath, delayed=12): +# delttime = 10800.0 +# print(sattime) +# sattimest = datetime.datetime.strptime(sattime, '%Y%m%d%H%M') +# satday = datetime.datetime(sattimest.year, sattimest.month, sattimest.day) + +# if sattimest.hour < 12: +# startfcsthour = 0 +# else: +# startfcsthour = 12 +# nwptime = satday - datetime.timedelta(hours=delayed) +# nwptimehour = nwptime + datetime.timedelta(hours=startfcsthour) +# fcsthour1 = int((sattimest - nwptimehour).total_seconds() / delttime) * int(delttime / 3600) +# fcsthour2 = fcsthour1 + int(delttime / 3600) +# fcsthour3 = fcsthour2 + int(delttime / 3600) +# nwptime = datetime.datetime.strftime(nwptimehour, '%Y%m%d%H') +# nwpttime1 = '%s%03d' % (nwptime, fcsthour1) +# nwpttime2 = '%s%03d' % (nwptime, fcsthour2) +# nwpttime3 = '%s%03d' % (nwptime, fcsthour3) +# _path_join = os.path.join +# nwppath = _path_join(nwppath, datetime.datetime.strftime(nwptimehour, '%Y'), +# datetime.datetime.strftime(nwptimehour, '%m')) +# nwpfile1 = _path_join(nwppath, 'gmf.gra.' + nwpttime1 + '.grb2') +# nwpfile2 = _path_join(nwppath, 'gmf.gra.' + nwpttime2 + '.grb2') +# nwpfile3 = _path_join(nwppath, 'gmf.gra.' + nwpttime3 + '.grb2') +# sfcfile1 = 'None' +# sfcfile2 = 'None' +# sfcfile3 = 'None' +# nwpt1 = nwptimehour + datetime.timedelta(hours=fcsthour1) +# nwpt2 = nwptimehour + datetime.timedelta(hours=fcsthour2) +# nwpt3 = nwptimehour + datetime.timedelta(hours=fcsthour3) +# nwptime1 = datetime.datetime.strftime(nwpt1, '%Y%m%d%H') + '00' +# nwptime2 = datetime.datetime.strftime(nwpt2, '%Y%m%d%H') + '00' +# nwptime3 = datetime.datetime.strftime(nwpt3, '%Y%m%d%H') + '00' +# print((nwptime1, nwptime2, nwptime3)) +# print(nwpfile1, nwpfile2, nwpfile3) +# return (nwpfile1, nwpfile2, nwpfile3, sfcfile1, sfcfile2, sfcfile3), (nwptime1, nwptime2, nwptime3) + + +###makebt,ConvertHDF +VALID_RANGE = dict( + LandSeaMask=[0, 7], + clmnwp=[0, 1], + seaice=[0, 1], + qcmark=[0, 1], + SatAzimuth=[0, 36000], + SatZenith=[0, 18000], + SunAzimuth=[0, 36000], + SunZenith=[0, 18000], + lat=[-90, 90], + lon=[-180, 360.], + u10m=[-100, 100], + v10m=[-100, 100], + bt=[5000, 40000], +) +# 根据类型选择填充值 +FV = dict(u2=0xFFFF, i2=0x8000, f4=-9999.9, f8=-9999.9, u1=0xFF, i1=0x80) + + +def headType(nlevel): + return [ + ('n', 'f4'), + ('year', 'f4'), + ('month', 'f4'), + ('day', 'f4'), + ('CO2', 'f4', nlevel), + ('CH4', 'f4', nlevel), + ('N2O', 'f4', nlevel), + ('CO' , 'f4', nlevel), + ('P', 'f4', nlevel), + ('pix', 'f4'), + ('line', 'f4'), + ] + +import io +def mwork(nlevel, nchannel, fileout, filein1, filein2): + nlevel = int(nlevel) + nchannel = int(nchannel) + print nlevel + print nchannel + print filein2 + filein2.sort() + I2 = io.BytesIO() + for i in sorted(filein2,key=lambda x:int(x.split('/temp')[-1].split('_')[0])): + print i + with open(i,'rb') as f: + I2.write(f.read()) + with open(filein1, 'rb') as I1: + _mwork(I1, I2, fileout, nlevel, nchannel) + + +def _mwork(I1, I2, fileout, nlevel, nchannel): + head, = numpy.fromfile(I1, dtype=headType(nlevel), count=1) + dataType = numpy.dtype([ + ('x', 'f4'), + ('y', 'f4'), + ('lat', 'f4'), + ('lon', 'f4'), + ('SatAzimuth', 'f4'), + ('SatZenith', 'f4'), + ('SunAzimuth', 'f4'), + ('SunZenith', 'f4'), + ('psfc', 'f4'), + ('q2m', 'f4'), + ('t2m', 'f4'), + ('u10m', 'f4'), + ('v10m', 'f4'), + ('dem', 'f4'), + ('seaice', 'f4'), + ('LandSeaMask', 'f4'), + ('ts', 'f4'), + ('T', 'f4', nlevel), + ('q', 'f4', nlevel), + ('o3', 'f4', nlevel), + ('qcmark', 'f4'), + ('cloud', 'f4', (6,nlevel-1)), + ('cfrac', 'f4', nlevel-1), + ('obs', 'f4', nchannel), + ('cloudmask', 'f4'), + ('clmnwp', 'f4'), + ('emissivity', 'f4', nchannel), + ('time', 'f8'), ('11', 'f4',2) + ]) + print dataType.itemsize + + n = int(head['n']) + print n + I1.seek(0,2) + n=I1.tell()/dataType.itemsize-1 + l = int(head['line']) + p = int(head['pix']) + print n,l,p + I1.seek(dataType.itemsize, 0) + data = numpy.fromfile(I1, dtype=dataType, count=n) # pre + data2 = numpy.fromstring(I2.getvalue(), dtype=[('sim', 'f4', nchannel),('Qf', 'i4', nchannel)], count=n) # sim_result + # I2.close() + x = data['x'].astype('u4')-1 + y = data['y'].astype('u4')-1 + print fileout + with h5py.File(fileout, 'w') as f: + for i, j in ('LandSeaMask', 'u1'), ('clmnwp', 'u1'), ('seaice', 'u1'), ('qcmark','u1'), \ + ('SatAzimuth', 'u2'), ('SatZenith', 'u2'), ('SunAzimuth', 'u2'), ('SunZenith', 'u2'), \ + ('lat', 'f4'), ('lon', 'f4'), ('u10m', 'f4'), ('v10m', 'f4'): + d = numpy.full((l, p), fill_value=FV[j], dtype=j) + if j == 'u1': + tmp = data[i] + tmp[tmp<0] = 255 + d[y, x] = tmp + elif j == 'u2': + tmp = data[i] + d[y, x] = tmp * 100 + d[y, x][tmp<-998] = FV['u2'] + else: + d[y, x] = data[i] + f.create_dataset(i, data=d, compression=9).attrs.update( + Slope=numpy.array(0.01,'f4') if j == 'u2' else numpy.array(1,'f4'), + valid_range=VALID_RANGE.get(i, []) + ) + #bt_dype = 'f4' + #slope = numpy.array(1,'f4') + bt_dype = 'u2' + slope = numpy.array(0.01,'f4') + if nchannel ==1: + d = numpy.full((l, p), fill_value=FV[bt_dype], dtype=bt_dype) + else: + d = numpy.full((l, p, nchannel), fill_value=FV[bt_dype], dtype=bt_dype) + obs=data['obs'] + #d[y, x] = obs + obs[obs<-999] = 655.35 + print obs + d[y, x] = obs / slope + #d[y, x][obs<-998] = FV[bt_dype] + print(d) + f.create_dataset('BT_OBS', data=d, compression=9).attrs.update( + Slope=slope, valid_range=numpy.array(VALID_RANGE['bt'], dtype='i4')) + + if nchannel == 1: + d = numpy.full((l, p), fill_value=FV[bt_dype], dtype=bt_dype) + else: + d = numpy.full((l, p, nchannel), fill_value=FV[bt_dype], dtype=bt_dype) + + sim = data2['sim'] + sim[sim<0] = 655.35 + + d[y, x] = sim / slope + f.create_dataset('BT_SIM', data=d, compression=9).attrs.update( + Slope=slope, valid_range=numpy.array(VALID_RANGE['bt'], dtype='i4') + ) + + d = numpy.full((l, p, nchannel), fill_value=255, dtype='u1') + obs = data2['Qf'] + obs[obs<0] = 255 + d[y, x] = obs + f.create_dataset('QC_rttov', data=d, dtype='u1',compression=9) + + d = numpy.full((l,p), fill_value=-9999., dtype='f8') + tm = data['time'] + # tf = tm>0 + tm[tm<0]=-9999. + # d[y[tf],] = tm[tf] + d[y, x] = tm + f.create_dataset('timestamp', data=d, compression=9).attrs.update( + discription='seconds from 1970-01-01 00:00:00 UTC' + ) + + f.attrs.update( + G_TIME=time.strftime('%Y-%m-%d %H:%M:%S'), + MOUDLE='RTTOV 1.2', + BASEDATA='ERA5' + ) + + + + + + + +class dataset(object): + """ + Decorator that converts a method with a single self argument into a + property cached on the instance. + Optional ``name`` argument allows you to make cached dataset of other + methods. (e.g. url = dataset(get_absolute_url, name='url') ) + """ + + def __init__(self, func, name=None): + self.func = func + self.__doc__ = getattr(func, '__doc__') + self.name = name or func.__name__ + + def __get__(self, instance, cls=None): + if instance is None: + return self + res = instance.__dict__[self.name] = self.func(instance) + return res + +class satfilebase(object): + """Concrete satfile type. + + Constructors: + + Operators: + __new__() + + + Methods: + # fuzzyfile() + # generatepath() + Properties (readonly): + satname,instrument,regionaltype,datalevel,sattime,dataname,vesion + eg:/FY4A_DATA/FY4A/GIIRS/L1/IRD/REGX/2022/20220101/ + FY4A-_GIIRS-_N_REGX_1047E_L1-_IRD-_MULT_NUL_20220101000000_20220101001044_016KM_001V3.HDF + """ + def __new__(cls,filename): + self = object.__new__(cls) + self._obspath = filename + self._basename = os.path.basename(filename) + print(self._basename) + _spiltname = self._basename.split('_') + self._satname = _spiltname[0].replace('-','') + self._instrument = _spiltname[1].replace('-','') + self._regionaltype = _spiltname[3] + self._subastralPoint = _spiltname[4] + self._datalevel = _spiltname[5].replace('-','') + self._datatype = _spiltname[6].replace('-','') + self._channelname = _spiltname[7] + self._projection = _spiltname[8] + self._startime = _spiltname[9] + self._endtime = _spiltname[10] + self._resolution = _spiltname[11] + self._vesion = _spiltname[12][:5] + return self + + @property + def obspath(self): + return self._obspath + @property + def basename(self): + return self._basename + @property + def startime(self): + return self._startime + @property + def endtime(self): + return self._endtime + @property + def instrument(self): + return self._instrument + @property + def regionaltype(self): + return self._regionaltype + @property + def datalevel(self): + return self._datalevel + @property + def datatype(self): + return self._datatype + @property + def vesion(self): + return self._vesion + + + +class bgbase(satfilebase): + def __new__(cls,filename,options): + # self = object.__new__(cls) + self = super(bgbase,cls).__new__(cls,filename) + + settings = options['settings'] + self._nwpname = settings['NWP'] + self._nwpresolution = settings['NWP_resolution'] + + path = options['path'] + self._configpath = path['configpath'] + self._nwppath = path['NWPpath'] + self._workpath = path['bgworkpath'] + ### + add ='/%s/%s/%s/%s/%s/'%(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8]) + self._outpath = path['bgoutpath']+add + if not os.path.exists(self._outpath): + os.makedirs(self._outpath) + print(self._startime) + if datetime.datetime.strptime(self._startime,'%Y%m%d%H%M%S')