Changeset 338 in lmdz_wrf for trunk/tools/validation_sim.py


Ignore:
Timestamp:
Feb 28, 2015, 6:11:34 PM (10 years ago)
Author:
lfita
Message:

Value of 'it' when searching for values has to be from 'coindtvalues' !!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/validation_sim.py

    r337 r338  
    22# L. Fita, LMD-Jussieu. February 2015
    33## e.g. sfcEneAvigon # validation_sim.py -d X@west_east@None,Y@south_north@None,T@Time@time -D X@XLONG@longitude,Y@XLAT@latitude,T@time@time -k single-station -l 4.878773,43.915876,12. -o /home/lluis/DATA/obs/HyMeX/IOP15/sfcEnergyBalance_Avignon/OBSnetcdf.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v HFX@H,LH@LE,GRDFLX@G
    4 ## e.g. AIREP # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@time -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@alti,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/AIREP/2012/10/AIREP_121018.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFT@t
     4## e.g. AIREP # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@time -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@alti,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/AIREP/2012/10/AIREP_121018.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFt@t
    55## e.g. ATRCore # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@CFtime -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@altitude,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/ATRCore/V3/ATR_1Hz-HYMEXBDD-SOP1-v3_20121018_as120051.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFT@air_temperature@subc@273.15
    66## e.g. BAMED # validation_sim.py -d X@west_east@lon2D,Y@south_north@lat2D,Z@bottom_top@z2D,T@Time@CFtime -D X@XLONG@longitude,Y@XLAT@latitude,Z@WRFz@altitude,T@time@time -k trajectory -o /home/lluis/DATA/obs/HyMeX/IOP15/BAMED/BAMED_SOP1_B12_TOT5.nc -s /home/lluis/PY/wrfout_d01_2012-10-18_00:00:00.tests -v WRFT@tas_north
     
    664664                quit(-1)
    665665
    666             print type(ncobj.variables)
    667    
    668666            self.dimensions = dimensions
    669667            self.shape = shape
     
    672670    def __getitem__(self,elem):
    673671        return self.__values[elem]
    674 
    675672
    676673####### ###### ##### #### ### ## #
     
    956953                        stationpos[0] = stsimpos[iid]
    957954                    iid = iid + 1
    958                 if stationpos[0] == 0 and stationpos[1] == 0: notfound[it] = 1
     955                if stationpos[0] == 0 or stationpos[1] == 0: notfound[it] = 1
    959956
    960957                trajpos[0,it] = stationspos[0]
     
    11051102        if dims.has_key('Z'):
    11061103            for it in range(Ncoindt):
    1107                 if notfound[it] == 0:
    1108                     ito = int(coindtvalues[it,1])
    1109                     trajpos[2,ito] = index_mat(valdimsim['Z'][it,:,trajpos[1,ito],   \
    1110                      trajpos[0,ito]], valdimobs['Z'][ito])
     1104                ito = int(coindtvalues[it,1])
     1105                if notfound[ito] == 0:
     1106                    trajpos[2,ito] = index_mat(valdimsim['Z'][coindtvalues[it,0],:,  \
     1107                      trajpos[1,ito],trajpos[0,ito]], valdimobs['Z'][ito])
    11111108                    slicev = dims['X'][0]+':'+str(trajpos[0,ito]) + '|' +            \
    11121109                      dims['Y'][0]+':'+str(trajpos[1,ito]) + '|' +                   \
     
    11151112                    slicevar, dimslice = slice_variable(ovsim, slicev)
    11161113                    simobsvalues.append([ slicevar, ovobs[int(ito)]])
    1117                     slicev = dims['X'][0] + ':' + str(trajpos[0,ito]-Ngrid) + '@' +  \
    1118                       str(trajpos[0,ito]+Ngrid+1) + '|' + dims['Y'][0] + ':' +       \
    1119                       str(trajpos[1,ito]-Ngrid) + '@' + str(trajpos[1,ito]+Ngrid+1)+ \
    1120                       '|' + dims['Z'][0] + ':' + str(trajpos[2,ito]-Ngrid) + '@' +   \
    1121                       str(trajpos[2,ito]+Ngrid+1) + '|' + dims['T'][0] + ':' +       \
    1122                       str(int(coindtvalues[it,0]))
     1114                    minx = np.max([trajpos[0,ito]-Ngrid,0])
     1115                    maxx = np.min([trajpos[0,ito]+Ngrid+1,ovsim.shape[3]])
     1116                    miny = np.max([trajpos[1,ito]-Ngrid,0])
     1117                    maxy = np.min([trajpos[1,ito]+Ngrid+1,ovsim.shape[2]])
     1118                    minz = np.max([trajpos[2,ito]-Ngrid,0])
     1119                    maxz = np.min([trajpos[2,ito]+Ngrid+1,ovsim.shape[1]])
     1120
     1121                    slicev = dims['X'][0] + ':' + str(minx) + '@' + str(maxx) + '|' +\
     1122                      dims['Y'][0] + ':' + str(miny) + '@' + str(maxy) + '|' +       \
     1123                      dims['Z'][0] + ':' + str(minz) + '@' + str(maxz) + '|' +       \
     1124                      dims['T'][0] + ':' + str(int(coindtvalues[it,0]))
    11231125                    slicevar, dimslice = slice_variable(ovsim, slicev)
    1124                     simobsSvalues[it,:,:,:] = slicevar
     1126
     1127                    sliceS = []
     1128                    sliceS.append(it)
     1129                    sliceS.append(slice(0,maxz-minz))
     1130                    sliceS.append(slice(0,maxy-miny))
     1131                    sliceS.append(slice(0,maxx-minx))
     1132                   
     1133                    simobsSvalues[tuple(sliceS)] = slicevar
    11251134                    if ivar == 0:
    11261135                        trjsim[0,it] = trajpos[0,ito]
     
    11741183    if dims.has_key('Z'):
    11751184        newdim = onewnc.createDimension('zaround',Ngrid*2+1)
    1176         newvar = onewnc.createVariable( valvars[ivar][0] + 'around', 'f',            \
     1185        newvar = onewnc.createVariable(valvars[ivar][0] + 'around', 'f',            \
    11771186          ('time','zaround','yaround','xaround'), fill_value=fillValueF)
    11781187    else:
    1179         newvar = onewnc.createVariable( valvars[ivar][0] + 'around', 'f',            \
     1188        newvar = onewnc.createVariable(valvars[ivar][0] + 'around', 'f',            \
    11801189          ('time','yaround','xaround'), fill_value=fillValueF)
    11811190
     
    11851194
    11861195# Statistics
    1187     newvar = onewnc.createVariable(varsimobs + 'staround', 'f', ('time','stats'),   \
    1188       fill_value=fillValueF)
     1196    newvar = onewnc.createVariable(valvars[ivar][0] + 'staround', 'f',               \
     1197      ('time','stats'), fill_value=fillValueF)
    11891198    descvar = 'around simulated statisitcs: ' + valvars[ivar][0]
    11901199    basicvardef(newvar, varsimobs + 'staround', descvar, ovobs.getncattr('units'))
Note: See TracChangeset for help on using the changeset viewer.