def get_front_end(src_data, src_file): print '****** src_data: ', src_data print '****** src_file: ', src_file if src_data == 'airs': src_front_end = FEAIRS.front_end_airs(src_file) elif src_data == 'amsr': src_front_end = FEA.front_end_amsr(src_file) elif src_data == 'caliop05kmALayer': # Caliop src_front_end = FE_CALIOP_05KMALAY.front_end_caliop_05km_alay(src_file) elif src_data == 'caliop05kmCLayer': # Caliop src_front_end = FE_CALIOP_05KMCLAY.front_end_caliop_05km_clay(src_file) elif src_data == 'caliop05kmCProfile': # Caliop src_front_end = FE_CALIOP_05KMCPRO.front_end_caliop_05km_cpro(src_file) elif src_data == 'caliop40kmAProfile': # Caliop src_front_end = FE_CALIOP_40KMAPRO.front_end_caliop_40km_apro(src_file) elif src_data == 'caliopVFM': # Caliop src_front_end = FE_CALIOP_VFM.front_end_caliop_vfm(src_file) elif src_data == 'ceres': src_front_end = FECERES.front_end_ceres(src_file) elif src_data == 'mls-temp': src_front_end = FEMLS_TEMP.front_end_mls_temp(src_file) elif src_data == 'mls-iwc': src_front_end = FEMLS_IWC.front_end_mls_iwc(src_file) elif src_data == 'mls-h2o': src_front_end = FEMLS_H2O.front_end_mls_h2o(src_file) elif src_data == 'mls-co': src_front_end = FEMLS_CO.front_end_mls_co(src_file) elif src_data == 'mls-o3': src_front_end = FEMLS_O3.front_end_mls_o3(src_file) elif src_data == 'mls-hno3': src_front_end = FEMLS_HNO3.front_end_mls_hno3(src_file) elif src_data == 'modis-aerosol': src_front_end = FEMODIS_AEROSOL.front_end_modis_aerosol(src_file) elif src_data == 'modis-cloud-5km': src_front_end = FEMODIS_CLOUD_5KM.front_end_modis_cloud_5km(src_file) elif src_data == 'modis-cloud-1km': src_front_end = FEMODIS_CLOUD_1KM.front_end_modis_cloud_1km(src_file) elif src_data == 'ecmwf-idaily-surface': src_front_end = FEECMWF_IDAILY_SURFACE.front_end_ecmwf_idaily_surface(src_file) elif src_data == 'ecmwf-idaily-plevels': src_front_end = FEECMWF_IDAILY_PLEVELS.front_end_ecmwf_idaily_plevels(src_file) elif src_data == 'ecmwf-yotc-aos-1.5deg': src_front_end = FEECMWF_YOTC_AOS_1P5DEG.front_end_ecmwf_yotc_aos_1p5deg(src_file) ### elif src_data == 'ecmwf-yotc-oaml-1.5deg': ### src_front_end = FEECMWF_YOTC_OAML_1P5DEG.front_end_ecmwf_yotc_oaml_1p5deg(src_file) ### elif src_data == 'ecmwf-yotc-oapl-1.5deg': ### src_front_end = FEECMWF_YOTC_OAPL_1P5DEG.front_end_ecmwf_yotc_oapl_1p5deg(src_file) elif src_data == 'ecmwf-yotc-aos-0.25deg': src_front_end = FEECMWF_YOTC_AOS_0P25DEG.front_end_ecmwf_yotc_aos_0p25deg(src_file) elif src_data == 'ecmwf-yotc-oaml-0.25deg': src_front_end = FEECMWF_YOTC_OAML_0P25DEG.front_end_ecmwf_yotc_oaml_0p25deg(src_file) elif src_data == 'ecmwf-yotc-oapl-0.25deg': src_front_end = FEECMWF_YOTC_OAPL_0P25DEG.front_end_ecmwf_yotc_oapl_0p25deg(src_file) elif src_data.find('cloudsat') >= 0: src_front_end = FEC.front_end_cloudsat(src_file) else: print '****** Error in get_front_end: source data set not supported yet !' sys.exit(1) return src_front_end
def test_airs(): airs_file = "AIRS.2006.01.01.001.L2.RetStd.v5.0.14.0.G07291112013.hdf" print "****** Reading AIRS data from file: ", airs_file airs = FEAIRS.front_end_airs(airs_file) # Test 2D reshape and reorder. A 1D array should result with the # elements reordered per the order specified below. #myname = 'var2d1d' #myorder = [9, 0, 2, 4, 3, 6, 5, 7, 1, 8] #mydata = N.array([[0.5, 0.2, 0.1, 0.3, 0.4],[1.5, 1.2, 1.1, 1.3, 1.4]]) #print 'Testing 2d to 1d reshape and reorder' #print myname, ' is of shape ', mydata.shape #print mydata #mydata = airs.process_2d(myname, mydata, myorder) #print myname, ' is of shape ', mydata.shape #print 'order requested is ', myorder #print mydata # Test 3D reshape and reorder. A 2D array should result with the # elements reordered per the order specified below. The inner-most # elements should remain paired with one another. myname = "contrived data" myorder = [9, 0, 2, 4, 3, 6, 5, 7, 1, 8] mydata = N.array([[[0.5,0.55,0.56], [0.2,0.25,0.26], [0.1,0.15,0.16], [0.3,0.35,0.36], [0.4,0.45,0.46]], [[1.5,1.55,1.56], [1.2,1.25,1.26], [1.1,1.15,1.16], [1.3,1.35,1.36], [1.4,1.45,1.46]]]) print 'Testing AIRS 3d to 2d reshape and reorder' print 'AIRS data is originally of shape ', mydata.shape #print 'input data = ', mydata mydata = airs.process_3d(myname, mydata, myorder) print myname, ' is now of shape ', mydata.shape print 'order requested along axis 0 is ', myorder #print 'actual results = ', mydata myresult = N.array([[ 1.4, 1.45, 1.46], [ 0.5,0.55,0.56], [ 0.1,0.15,0.16], [ 0.4,0.45,0.46], [ 0.3,0.35,0.36], [ 1.2,1.25,1.26], [ 1.5,1.55,1.56], [ 1.1,1.15,1.16], [ 0.2,0.25,0.26], [ 1.3,1.35,1.36]]) #print 'desired results = ', myresult if test_equal(mydata, myresult): print 'AIRS PASSED' else: print 'AIRS FAILED'
# to the middle end for collocation processing # CloudSat file name cs_file = "2007048000847_04291_CS_2B-CWC-RO_GRANULE_P_R04_E02.hdf" # AIRS file name airs_file = "AIRS.2008.01.03.001.L2.RetStd.v5.2.2.0.G08064123231.hdf" # AMSR file name am_file = "amsre_20070217v5.gz" # Instantiate a middle end class midEnd = MD.middle_end() # Construct AIRS data structure in the front end and read in the data print "****** Reading AIRS data from file: ", airs_file ais = FEAIRS.front_end_airs(airs_file) # Pass the AIRS grid info to the middle end grid data structure # Get time info as an array midEnd.set_target_time(ais.get_time()) print "AIRS UTC Time = ", midEnd.get_target_time() # print 'AIRS UTC Time Range = ', min(midEnd.get_target_time()), max(midEnd.get_target_time()) print "AIRS UTC Time Size = ", midEnd.get_target_time().size print "" # Get latitude info as an array midEnd.target_latitude = ais.get_latitude() print "AIRS Latitude = ", midEnd.target_latitude # print 'AIRS Latitude Range = ', min(midEnd.target_latitude), max(midEnd.target_latitude) print "AIRS Latitude Size = ", midEnd.target_latitude.size print ""
def get_front_end(src_data, src_file): print '****** src_data: ', src_data print '****** src_file: ', src_file if src_data == 'airs': src_front_end = FEAIRS.front_end_airs(src_file) elif src_data == 'amsr': src_front_end = FEA.front_end_amsr(src_file) elif src_data == 'caliop05kmALayer': # Caliop src_front_end = FE_CALIOP_05KMALAY.front_end_caliop_05km_alay(src_file) elif src_data == 'caliop05kmCLayer': # Caliop src_front_end = FE_CALIOP_05KMCLAY.front_end_caliop_05km_clay(src_file) elif src_data == 'caliop05kmCProfile': # Caliop src_front_end = FE_CALIOP_05KMCPRO.front_end_caliop_05km_cpro(src_file) elif src_data == 'caliop40kmAProfile': # Caliop src_front_end = FE_CALIOP_40KMAPRO.front_end_caliop_40km_apro(src_file) elif src_data == 'caliopVFM': # Caliop src_front_end = FE_CALIOP_VFM.front_end_caliop_vfm(src_file) elif src_data == 'ceres': src_front_end = FECERES.front_end_ceres(src_file) elif src_data == 'mls-temp': src_front_end = FEMLS_TEMP.front_end_mls_temp(src_file) elif src_data == 'mls-iwc': src_front_end = FEMLS_IWC.front_end_mls_iwc(src_file) elif src_data == 'mls-h2o': src_front_end = FEMLS_H2O.front_end_mls_h2o(src_file) elif src_data == 'mls-co': src_front_end = FEMLS_CO.front_end_mls_co(src_file) elif src_data == 'mls-o3': src_front_end = FEMLS_O3.front_end_mls_o3(src_file) elif src_data == 'mls-hno3': src_front_end = FEMLS_HNO3.front_end_mls_hno3(src_file) elif src_data == 'modis-aerosol': src_front_end = FEMODIS_AEROSOL.front_end_modis_aerosol(src_file) elif src_data == 'modis-cloud-5km': src_front_end = FEMODIS_CLOUD_5KM.front_end_modis_cloud_5km(src_file) elif src_data == 'modis-cloud-1km': src_front_end = FEMODIS_CLOUD_1KM.front_end_modis_cloud_1km(src_file) elif src_data == 'ecmwf-idaily-surface': src_front_end = FEECMWF_IDAILY_SURFACE.front_end_ecmwf_idaily_surface( src_file) elif src_data == 'ecmwf-idaily-plevels': src_front_end = FEECMWF_IDAILY_PLEVELS.front_end_ecmwf_idaily_plevels( src_file) elif src_data == 'ecmwf-yotc-aos-1.5deg': src_front_end = FEECMWF_YOTC_AOS_1P5DEG.front_end_ecmwf_yotc_aos_1p5deg( src_file) ### elif src_data == 'ecmwf-yotc-oaml-1.5deg': ### src_front_end = FEECMWF_YOTC_OAML_1P5DEG.front_end_ecmwf_yotc_oaml_1p5deg(src_file) ### elif src_data == 'ecmwf-yotc-oapl-1.5deg': ### src_front_end = FEECMWF_YOTC_OAPL_1P5DEG.front_end_ecmwf_yotc_oapl_1p5deg(src_file) elif src_data == 'ecmwf-yotc-aos-0.25deg': src_front_end = FEECMWF_YOTC_AOS_0P25DEG.front_end_ecmwf_yotc_aos_0p25deg( src_file) elif src_data == 'ecmwf-yotc-oaml-0.25deg': src_front_end = FEECMWF_YOTC_OAML_0P25DEG.front_end_ecmwf_yotc_oaml_0p25deg( src_file) elif src_data == 'ecmwf-yotc-oapl-0.25deg': src_front_end = FEECMWF_YOTC_OAPL_0P25DEG.front_end_ecmwf_yotc_oapl_0p25deg( src_file) elif src_data.find('cloudsat') >= 0: src_front_end = FEC.front_end_cloudsat(src_file) else: print '****** Error in get_front_end: source data set not supported yet !' sys.exit(1) return src_front_end
# The front end reads a CloudSat HDF file and passes the geolocation informaiton # to the middle end for collocation processing # CloudSat file name cs_file = "2007048000847_04291_CS_2B-CWC-RO_GRANULE_P_R04_E02.hdf" # AIRS file name airs_file = "AIRS.2008.01.03.001.L2.RetStd.v5.2.2.0.G08064123231.hdf" # AMSR file name am_file = "amsre_20070217v5.gz" # Instantiate a middle end class midEnd = MD.middle_end() # Construct AIRS data structure in the front end and read in the data print "****** Reading AIRS data from file: ", airs_file ais = FEAIRS.front_end_airs(airs_file) # Pass the AIRS grid info to the middle end grid data structure # Get time info as an array midEnd.set_target_time(ais.get_time()) print 'AIRS UTC Time = ', midEnd.get_target_time() #print 'AIRS UTC Time Range = ', min(midEnd.get_target_time()), max(midEnd.get_target_time()) print 'AIRS UTC Time Size = ', midEnd.get_target_time().size print '' # Get latitude info as an array midEnd.target_latitude = ais.get_latitude() print 'AIRS Latitude = ', midEnd.target_latitude #print 'AIRS Latitude Range = ', min(midEnd.target_latitude), max(midEnd.target_latitude) print 'AIRS Latitude Size = ', midEnd.target_latitude.size print ''