Merge branch 'master' of http://123.249.105.92:4000/Zhangqiankun/FY4B_C_SPMS
commit
39b09bdca5
|
@ -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)
|
|
@ -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")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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()
|
|
@ -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())
|
|
@ -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()
|
|
@ -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()
|
|
@ -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)
|
|
@ -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)
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
|
@ -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)
|
||||||
|
|
|
@ -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)&(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)
|
|
@ -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)
|
|
@ -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)&(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)
|
||||||
|
|
|
@ -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<fcschoice:
|
||||||
|
ndelayed = (delayed//fcschoice+1)*fcschoice
|
||||||
|
daychour = fcschoice*((sattimest.hour+ndelayed-delayed)//fcschoice)
|
||||||
|
nwptfcstimest = satdayc- datetime.timedelta(hours=ndelayed)+datetime.timedelta(hours= daychour)
|
||||||
|
# else:
|
||||||
|
# daychour = fcschoice*(sattimest.hour//fcschoice)
|
||||||
|
# nwptfcstimest = satdayc- datetime.timedelta(hours=delayed)+datetime.timedelta(hours= daychour)
|
||||||
|
|
||||||
|
fcsthours=int((sattimest-nwptfcstimest).total_seconds()/delttime)*int(delttime/3600)
|
||||||
|
nwptfcstime=datetime.datetime.strftime(nwptfcstimest,'%Y%m%d%H')
|
||||||
|
nwppath = self._nwppath+self._add
|
||||||
|
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 = [nwptime1]
|
||||||
|
nwptime = [nwpt1]
|
||||||
|
nwp1file = [nwpfile1]
|
||||||
|
nwp2file = [None]
|
||||||
|
if nums > 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)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -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()
|
||||||
|
|
||||||
|
|
Binary file not shown.
|
@ -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()
|
|
@ -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/
|
|
@ -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/
|
|
@ -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/
|
|
@ -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/
|
|
@ -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/
|
|
@ -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/
|
|
@ -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
|
||||||
|
|
Binary file not shown.
|
@ -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/
|
|
@ -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/
|
|
@ -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/
|
|
@ -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')<datetime.datetime.strptime('202305220001','%Y%m%d%H%M'):
|
||||||
|
self._nwpresolution = 0.25
|
||||||
|
else:
|
||||||
|
self._nwpresolution = 0.125
|
||||||
|
|
||||||
|
staticfile=options['staticfile']
|
||||||
|
self._lsmfile = staticfile['lsmfile']
|
||||||
|
self._elefile = staticfile['elefile']
|
||||||
|
self._coeffile = staticfile['coeffile']
|
||||||
|
self._emispath = staticfile['emispath']
|
||||||
|
|
||||||
|
if self._instrument =='GIIRS':
|
||||||
|
###bg chan begin
|
||||||
|
if 'channelbegin' in settings.keys()and isinstance(settings['channelbegin'],dict):
|
||||||
|
if 'LW' in settings['channelbegin'].keys():
|
||||||
|
self._lwchannelbegin = settings['channelbegin']['LW']
|
||||||
|
else:
|
||||||
|
self._lwchannelbegin = 1
|
||||||
|
if 'MW' in settings['channelbegin'].keys():
|
||||||
|
self._mwchannelbegin = settings['channelbegin']['MW']
|
||||||
|
else:
|
||||||
|
self._mwchannelbegin = 1
|
||||||
|
else:
|
||||||
|
self._lwchannelbegin = 1
|
||||||
|
self._mwchannelbegin = 1
|
||||||
|
|
||||||
|
|
||||||
|
self._spectype='IR'
|
||||||
|
self._emispath=self._emispath+'/'+ self._spectype
|
||||||
|
if 'bgexepath' in staticfile.keys()and isinstance(staticfile['bgexepath'],dict):
|
||||||
|
if 'LW' in staticfile['bgexepath'].keys():
|
||||||
|
self._bglwexe = staticfile['bgexepath']['LW']
|
||||||
|
else:
|
||||||
|
self._bglwexe = '%s/produce_background_data_%s_%s_%s_LW.exe'%(self._workpath,self._nwpname,self._satname[2:],self._instrument)
|
||||||
|
if 'MW' in staticfile['bgexepath'].keys():
|
||||||
|
self._bgmwexe = staticfile['bgexepath']['MW']
|
||||||
|
else:
|
||||||
|
self._bgmwexe = '%s/produce_background_data_%s_%s_%s_MW.exe'%(self._workpath,self._nwpname,self._satname[2:],self._instrument)
|
||||||
|
else:
|
||||||
|
self._bglwexe = '%s/produce_background_data_%s_%s_%s_LW.exe'%(self._workpath,self._nwpname,self._satname[2:],self._instrument)
|
||||||
|
self._bgmwexe = '%s/produce_background_data_%s_%s_%s_MW.exe'%(self._workpath,self._nwpname,self._satname[2:],self._instrument)
|
||||||
|
self._bgexe={'LW':self._bglwexe,'MW':self._bgmwexe}
|
||||||
|
|
||||||
|
lwoutfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_sea_profiles_LW.dat'
|
||||||
|
lwoutcloudy = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_cloudy_profiles_LW.dat'
|
||||||
|
lwoutland = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_land_profiles_LW.dat'
|
||||||
|
mwoutfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_sea_profiles_MW.dat'
|
||||||
|
mwoutcloudy = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_cloudy_profiles_MW.dat'
|
||||||
|
mwoutland = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_land_profiles_MW.dat'
|
||||||
|
self._outfile = {'LW':lwoutfile,'MW':mwoutfile}
|
||||||
|
self._outcloudy = {'LW':lwoutcloudy,'MW':mwoutcloudy}
|
||||||
|
self._outland = {'LW':lwoutland,'MW':mwoutland}
|
||||||
|
elif self._instrument =='AGRI':
|
||||||
|
self._spectype='IR'
|
||||||
|
self._emispath=self._emispath+'/'+ self._spectype
|
||||||
|
self._bgexe = '%s/produce_background_data_%s_%s_%s.exe'%(self._workpath,self._nwpname,self._satname[2:],self._instrument)
|
||||||
|
self._outfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_sea_profiles.dat'
|
||||||
|
self._outcloudy = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_cloudy_profiles.dat'
|
||||||
|
self._outland = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_land_profiles.dat'
|
||||||
|
|
||||||
|
self._configfile = None
|
||||||
|
return self
|
||||||
|
|
||||||
|
def match_nwp(self):
|
||||||
|
A = GRAPES.GRAPESMETA()
|
||||||
|
nwpfile,nwptime,_ = A.match(self._startime[0:12],nums=3,delttime=10800,delayed=6,fcschoice=12,fcssame = True)
|
||||||
|
self._nwpfile = nwpfile
|
||||||
|
self._nwptime = nwptime
|
||||||
|
if (os.path.exists(nwpfile[0]))&(os.path.exists(nwpfile[1]))&(os.path.exists(nwpfile[2])):
|
||||||
|
return True
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
|
def make_config(self,wmtype='',obsfile='None',geofile='None'):
|
||||||
|
if self._instrument == 'GIIRS' and (not wmtype in ("MW","LW") ):
|
||||||
|
print('giirs need input wmtype')
|
||||||
|
exit()
|
||||||
|
if self._instrument == 'AGRI':
|
||||||
|
print(obsfile)
|
||||||
|
if obsfile!='None':
|
||||||
|
obsfile = obsfile
|
||||||
|
else:
|
||||||
|
dirname = os.path.dirname(self._obspath)
|
||||||
|
obsfile = dirname.replace('GEO','4000M')+'/'+self._basename.replace('GEO','FDI')
|
||||||
|
if geofile!="None":
|
||||||
|
geofile = geofile
|
||||||
|
else:
|
||||||
|
geofile = '/fy4_ads_data/FY4B/data/1330E/FY4B_OBI_4000M_NOM_LATLON.HDF' #default
|
||||||
|
# /FY4B_DATA/AGRI/L1/FDI/DISK/GEO/2022/20220415/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_20220415040000_20220415041459_4000M_V0001.HDF
|
||||||
|
# /FY4B_DATA/AGRI/L1/FDI/DISK/4000M/2022/20220415/FY4B-_AGRI--_N_DISK_1330E_L1-_FDI-_MULT_NOM_20220415031500_20220415032959_4000M_V0001.HDF
|
||||||
|
self._configfile = self._configpath+'/configure_bg_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime)
|
||||||
|
print('*****',self._configfile)
|
||||||
|
elif self._instrument == 'GHI':
|
||||||
|
if not obsfile=='None':
|
||||||
|
obsfile = obsfile
|
||||||
|
else:
|
||||||
|
dirname = os.path.dirname(self._obspath)
|
||||||
|
obsfile = dirname.replace('GEO','2000M')+'/'+self._basename.replace('GEO','FDI')
|
||||||
|
# /FY4B_DATA/AGRI/L1/FDI/DISK/GEO/2022/20220415/FY4B-_AGRI--_N_DISK_1330E_L1-_GEO-_MULT_NOM_20220415040000_20220415041459_4000M_V0001.HDF
|
||||||
|
# /FY4B_DATA/AGRI/L1/FDI/DISK/4000M/2022/20220415/FY4B-_AGRI--_N_DISK_1330E_L1-_FDI-_MULT_NOM_20220415031500_20220415032959_4000M_V0001.HDF
|
||||||
|
self._configfile = self._configpath+'/configure_bg_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime)
|
||||||
|
|
||||||
|
elif self._instrument == 'GIIRS':
|
||||||
|
obsfile='None'
|
||||||
|
geofile = 'None'
|
||||||
|
######conf
|
||||||
|
self._configfile = self._configpath+'/configure_bg_%s_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime,wmtype)
|
||||||
|
print self._configfile
|
||||||
|
# configfile = self._configpath+'/configure_%s_%s_%s_%s.txt'%(self.nwpname,self._basename[0:11]+self._startime,giirstype)
|
||||||
|
if not os.path.exists(self._configpath):
|
||||||
|
os.makedirs(self._configpath)
|
||||||
|
|
||||||
|
polar = 0
|
||||||
|
clmfile ='None'
|
||||||
|
delttime = 10800.0
|
||||||
|
with open(self._configfile,'w')as f:
|
||||||
|
|
||||||
|
f.write('&L1info\n')
|
||||||
|
f.write('satfilename=\'%s\'' % self._obspath +',\n')
|
||||||
|
f.write('obsfilename=\'%s\'' % obsfile +',\n')
|
||||||
|
f.write('clmfilename=\'%s\'' % clmfile +',\n')
|
||||||
|
f.write('coeffile=\'%s\'' % self._coeffile +',\n')
|
||||||
|
f.write('emispath=\'%s\'' % self._emispath +',\n')
|
||||||
|
f.write('spectype=\'%s\'' % self._spectype +',\n')
|
||||||
|
f.write('sattype=%s' % polar +',\n')
|
||||||
|
f.write('year=%s' % self._startime[0:4] +',\n')
|
||||||
|
f.write('month=%s' % self._startime[4:6] +',\n')
|
||||||
|
f.write('day=%s' % self._startime[6:8] +',\n')
|
||||||
|
if self._instrument == 'GIIRS'and wmtype=='MW':
|
||||||
|
f.write('channelbegin=%s' % self._mwchannelbegin +',\n')
|
||||||
|
f.write('/\n')
|
||||||
|
f.write('&nwpfileinfo\n')
|
||||||
|
f.write('nwpfilename1=\'%s\'' % self._nwpfile[0] +',\n')
|
||||||
|
f.write('nwpfilename2=\'%s\'' % self._nwpfile[1] +',\n')
|
||||||
|
f.write('nwpfilename3=\'%s\'' % self._nwpfile[2] +',\n')
|
||||||
|
f.write('sfcfilename1=\'%s\'' % self._nwpfile[3] +',\n')
|
||||||
|
f.write('sfcfilename2=\'%s\'' % self._nwpfile[4] +',\n')
|
||||||
|
f.write('sfcfilename3=\'%s\'' % self._nwpfile[5] +',\n')
|
||||||
|
f.write('lsmfilename=\'%s\'' % self._lsmfile +',\n')
|
||||||
|
f.write('elefilename=\'%s\'' % self._elefile +',\n')
|
||||||
|
f.write('geofilename=\'%s\'' % geofile +',\n')
|
||||||
|
f.write('time1=%s' % self._nwptime[0] +',\n')
|
||||||
|
f.write('time2=%s' % self._nwptime[1] +',\n')
|
||||||
|
f.write('time3=%s' % self._nwptime[2] +',\n')
|
||||||
|
f.write('delttime=%s' % delttime +',\n')
|
||||||
|
f.write('NWP_resolution=%s' % self._nwpresolution +',\n')
|
||||||
|
f.write('/\n')
|
||||||
|
f.write('&output\n')
|
||||||
|
if self._instrument == 'GIIRS':
|
||||||
|
|
||||||
|
f.write('outfilename=\'%s\'' % self._outfile[wmtype] +',\n')
|
||||||
|
f.write('outcloudy=\'%s\'' % self._outcloudy[wmtype] +',\n')
|
||||||
|
f.write('outland=\'%s\'' % self._outland[wmtype] +',\n')
|
||||||
|
else:
|
||||||
|
|
||||||
|
f.write('outfilename=\'%s\'' % self._outfile +',\n')
|
||||||
|
f.write('outcloudy=\'%s\'' % self._outcloudy +',\n')
|
||||||
|
f.write('outland=\'%s\'' % self._outland +',\n')
|
||||||
|
|
||||||
|
f.write('/\n')
|
||||||
|
return self._configfile
|
||||||
|
|
||||||
|
@property
|
||||||
|
def config(self):
|
||||||
|
return self._configfile
|
||||||
|
|
||||||
|
def del_config(self):
|
||||||
|
if os.path.exists(self._configfile):
|
||||||
|
os.remove(self._configfile)
|
||||||
|
print('del %s'% self._configfile)
|
||||||
|
|
||||||
|
def run(self,wmtype='None'):
|
||||||
|
if self._configfile is None:
|
||||||
|
print('config is not exist,please make config file!')
|
||||||
|
else:
|
||||||
|
if self._instrument=='GIIRS' and wmtype =='LW':
|
||||||
|
os.system('time %s %s' % ( self._bglwexe,self._configfile))
|
||||||
|
print('time %s %s' % (self._bglwexe,self._configfile))
|
||||||
|
#
|
||||||
|
os.system('rm -f /fy4_ads_data/stss_v2.0/FILE_GRAPES_inv/FY4B-_GIIRS*%s*'%(self._satname[0:10]))
|
||||||
|
elif self._instrument=='GIIRS' and wmtype =='MW':
|
||||||
|
os.system('time %s %s' % (self._bgmwexe,self._configfile))
|
||||||
|
print('time %s %s' % (self._bgmwexe,self._configfile))
|
||||||
|
os.system('rm -f /fy4_ads_data/stss_v2.0/FILE_GRAPES_inv/FY4B-_GIIRS*%s*'%(self._satname[0:10]))
|
||||||
|
else:
|
||||||
|
print('time %s %s' % ( self._bgexe,self._configfile))
|
||||||
|
os.system('time %s %s' % ( self._bgexe,self._configfile))
|
||||||
|
def del_bgfile(self,wmtype='None'):
|
||||||
|
if self._instrument=='GIIRS':
|
||||||
|
if os.path.exists(self._outfile[wmtype]):
|
||||||
|
os.remove(self._outfile[wmtype])
|
||||||
|
print('del %s'% self._outfile[wmtype])
|
||||||
|
if os.path.exists(self._outcloudy[wmtype]):
|
||||||
|
os.remove(self.outcloudy[wmtype])
|
||||||
|
print('del %s'% self.outcloudy[wmtype])
|
||||||
|
if os.path.exists(self._outland[wmtype]):
|
||||||
|
os.remove(self._outland[wmtype])
|
||||||
|
print('del %s'% self._outland[wmtype])
|
||||||
|
else:
|
||||||
|
if os.path.exists(self._outfile):
|
||||||
|
os.remove(self._outfile)
|
||||||
|
print('del %s'% self._outfile)
|
||||||
|
if os.path.exists(self._outcloudy):
|
||||||
|
os.remove(self.outcloudy)
|
||||||
|
print('del %s'% self.outcloudy)
|
||||||
|
if os.path.exists(self._outland):
|
||||||
|
os.remove(self._outland)
|
||||||
|
print('del %s'% self._outland)
|
||||||
|
|
||||||
|
|
||||||
|
class simbase(satfilebase):
|
||||||
|
def __new__(cls,filename,options):
|
||||||
|
# self = object.__new__(cls)
|
||||||
|
self = super(simbase,cls).__new__(cls,filename)
|
||||||
|
|
||||||
|
settings = options['settings']
|
||||||
|
self._nwpname = settings['NWP']
|
||||||
|
self._nwplevel = settings['NWP_level']
|
||||||
|
if self._instrument=="GIIRS":
|
||||||
|
self._nchannels = {'LW':settings['channels']['LW'],
|
||||||
|
'MW':settings['channels']['MW']}
|
||||||
|
else:
|
||||||
|
self._nchannels = settings['channels']
|
||||||
|
# self._IP = settings['IP']
|
||||||
|
self._numexe = settings['numexe']
|
||||||
|
path = options['path']
|
||||||
|
self._configpath = path['configpath']
|
||||||
|
self._bgfilepath = path['bgoutpath']
|
||||||
|
self._temppath = path['temppath']
|
||||||
|
self._outpath = path['simpath']
|
||||||
|
|
||||||
|
staticfile=options['staticfile']
|
||||||
|
self._coeffile = staticfile['coeffile']
|
||||||
|
self._emispath = staticfile['emispath']
|
||||||
|
self._simexe = staticfile['simexe']
|
||||||
|
self._spectype='IR'
|
||||||
|
self._emispath=self._emispath+'/'+ self._spectype
|
||||||
|
add ='/%s/%s/%s/%s/%s/'%(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8])
|
||||||
|
self._temppath = self._temppath+add
|
||||||
|
self._outpath = self._outpath+add
|
||||||
|
return self
|
||||||
|
|
||||||
|
def make_config(self,wmtype='None'):
|
||||||
|
|
||||||
|
|
||||||
|
if not os.path.exists(self._temppath):
|
||||||
|
os.makedirs(self._temppath)
|
||||||
|
print(self._outpath)
|
||||||
|
if not os.path.exists(self._outpath):
|
||||||
|
os.makedirs(self._outpath)
|
||||||
|
if not os.path.exists(self._configpath):
|
||||||
|
os.makedirs(self._configpath)
|
||||||
|
add ='/%s/%s/%s/%s/%s/'%(self._satname,self._instrument,self._nwpname,self._startime[0:4],self._startime[0:8])
|
||||||
|
self._bgfilepath +=add
|
||||||
|
# self._self._outfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_clear_sea_profiles.dat'
|
||||||
|
if self._instrument=='GIIRS':
|
||||||
|
self._configfile = self._configpath+'/configure_sim_%s_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime,wmtype)
|
||||||
|
self._outcloudy = self._bgfilepath+self._basename[0:44]+self._startime+'_'+self._resolution+'_cloudy_profiles_%s.dat'%(wmtype)
|
||||||
|
self._outbasename = self._basename[0:44]+self._startime+'_'+self._resolution+'_%s_BT.dat'%(wmtype)
|
||||||
|
self._outfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_%s_BT.HDF'%(wmtype)
|
||||||
|
nchannels = self._nchannels[wmtype]
|
||||||
|
if wmtype == "MW":
|
||||||
|
chanannelbegine = 722
|
||||||
|
else:
|
||||||
|
chanannelbegine = 1
|
||||||
|
else:
|
||||||
|
self._configfile = self._configpath+'/configure_sim_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime)
|
||||||
|
|
||||||
|
self._outcloudy = self._bgfilepath+self._basename[0:44]+self._startime+'_'+self._resolution+'_cloudy_profiles.dat'
|
||||||
|
# lwoutcloudy = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_cloudy_profiles_LW.dat'
|
||||||
|
self._outbasename = self._basename[0:44]+self._startime+'_'+self._resolution+'_BT.dat'
|
||||||
|
self._outfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_BT.HDF'
|
||||||
|
nchannels = self._nchannels
|
||||||
|
chanannelbegine = 1
|
||||||
|
#####
|
||||||
|
#wenjian
|
||||||
|
#####
|
||||||
|
# self._configfile = configfile
|
||||||
|
# if self._instrument == 'MERSI':
|
||||||
|
# obsfile = self.obspath.replace(self._datatype,self._datatype[3]+'000M')
|
||||||
|
# else:
|
||||||
|
# obsfile='None'
|
||||||
|
######config
|
||||||
|
|
||||||
|
# self._nvar=(20 + 3 * self._nwplevel + 7 * ((self._nwplevel-1)) +self._nchannels + self._nchannels + 4)
|
||||||
|
|
||||||
|
|
||||||
|
with open(self._configfile,'w')as f:
|
||||||
|
f.write('&L1info\n')
|
||||||
|
f.write('nchannels=%s' % nchannels +',\n')
|
||||||
|
f.write('channelbegin=%s' %chanannelbegine +',\n')
|
||||||
|
f.write('platformid=%s' % '1' +',\n')
|
||||||
|
f.write('satid=%s' % '23' +',\n')
|
||||||
|
f.write('insid=%s' % '1' +',\n')
|
||||||
|
f.write('coefffile=\'%s\'' % self._coeffile +',\n')
|
||||||
|
f.write('scattcoef_file=\'%s\'' % 'None' +',\n')
|
||||||
|
f.write('emisfilepath=\'%s\'' % self._emispath +',\n')
|
||||||
|
f.write('zeemancoef_file=\'%s\'' % 'None' +',\n')
|
||||||
|
f.write('/\n')
|
||||||
|
f.write('&nwpfileinfo\n')
|
||||||
|
f.write('spectype=%s' % self._spectype +',\n')
|
||||||
|
f.write('bkgfile=\'%s\'' % self._outcloudy +',\n')
|
||||||
|
f.write('nprofile=%s' % '5793312' +',\n')
|
||||||
|
f.write('nlevel=%s' % self._nwplevel +',\n')
|
||||||
|
f.write('/\n')
|
||||||
|
f.write('&output\n')
|
||||||
|
f.write('temppath=\'%s\'' % self._temppath +',\n')
|
||||||
|
f.write('outpath=\'%s\'' % self._outpath +',\n')
|
||||||
|
f.write('outfilename=\'%s\'' % self._outbasename +',\n')
|
||||||
|
f.write('/\n')
|
||||||
|
return self._configfile
|
||||||
|
|
||||||
|
# @property
|
||||||
|
def config(self,wmtype='None'):
|
||||||
|
if self._instrument=='GIIRS':
|
||||||
|
self._configfile = self._configpath+'/configure_sim_%s_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime,wmtype)
|
||||||
|
else:
|
||||||
|
self._configfile = self._configpath+'/configure_sim_%s_%s_%s.txt'%(self._nwpname,self._basename[0:11],self._startime)
|
||||||
|
return self._configfile
|
||||||
|
# @property
|
||||||
|
def outfile(self,wmtype='None'):
|
||||||
|
|
||||||
|
if self._instrument=='GIIRS':
|
||||||
|
self._outfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_%s_BT.HDF'%(wmtype)
|
||||||
|
else:
|
||||||
|
self._outfile = self._outpath+self._basename[0:44]+self._startime+'_'+self._resolution+'_BT.HDF'
|
||||||
|
return self._outfile
|
||||||
|
|
||||||
|
def del_config(self):
|
||||||
|
if os.path.exists(self._configfile):
|
||||||
|
os.remove(self._configfile)
|
||||||
|
print('del %s'% self._configfile)
|
||||||
|
|
||||||
|
def run(self,wmtype='None'):
|
||||||
|
if self._configfile is None:
|
||||||
|
print('config is not exist,please make config file!')
|
||||||
|
if self._instrument=='GIIRS':
|
||||||
|
self._tempfilename = self._temppath+'temp*_'+self._basename[0:44]+self._startime+'_'+self._resolution+'_%s_BT.dat'%(wmtype)
|
||||||
|
nchannels = self._nchannels[wmtype]
|
||||||
|
else:
|
||||||
|
self._tempfilename = self._temppath+'temp*_'+self._basename[0:44]+self._startime+'_'+self._resolution+'_BT.dat'
|
||||||
|
nchannels = self._nchannels
|
||||||
|
|
||||||
|
os.system('time mpirun -n %s %s %s'%(self._numexe,self._simexe,self._configfile))
|
||||||
|
self._tempfiles= glob.glob(self._tempfilename)
|
||||||
|
mwork(self._nwplevel,nchannels,self._outfile,self._outcloudy,self._tempfiles)
|
||||||
|
|
||||||
|
def run_nonrunexe(self,wmtype='None'):
|
||||||
|
# if self._configfile is None:
|
||||||
|
# print('config is not exist,please make config file!')
|
||||||
|
if self._instrument=='GIIRS':
|
||||||
|
self._tempfilename = self._temppath+'temp*_'+self._basename[0:44]+self._startime+'_'+self._resolution+'_%s_BT.dat'%(wmtype)
|
||||||
|
nchannels = self._nchannels[wmtype]
|
||||||
|
else:
|
||||||
|
self._tempfilename = self._temppath+'temp*_'+self._basename[0:44]+self._startime+'_'+self._resolution+'_BT.dat'
|
||||||
|
nchannels = self._nchannels
|
||||||
|
|
||||||
|
# os.system('time mpirun -n %s %s %s'%(self._numexe,self._simexe,self._configfile))
|
||||||
|
self._tempfiles= glob.glob(self._tempfilename)
|
||||||
|
# print(self._nwplevel,nchannels,self._outfile,self._outcloudy,self._tempfiles)
|
||||||
|
mwork(self._nwplevel,nchannels,self._outfile,self._outcloudy,self._tempfiles)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def del_temp(self):
|
||||||
|
if self._tempfiles:
|
||||||
|
os.system('rm -f '+self._tempfilename)
|
||||||
|
print('del %s'% self._tempfiles)
|
||||||
|
|
||||||
|
|
||||||
|
def del_bgfile(self):
|
||||||
|
if os.path.exists(self._outcloudy):
|
||||||
|
os.remove(self._outcloudy)
|
||||||
|
print('del %s'% self._outcloudy)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue