3 from copy
import deepcopy
4 from jediApplicationArgs
import depbgGroup, depanGroup
8 import plot_utils
as pu
20 obsVarAlt =
'altitude'
21 obsVarACI =
'asymmetric_cloud_impact'
22 obsVarBT =
'brightness_temperature'
23 obsVarBTClear = obsVarBT+
'_assuming_clear_sky'
24 obsVarCldFrac =
'cloud_area_fraction'
27 obsVarLT =
'LocalTime'
28 obsVarLandFrac=
'land_area_fraction'
29 obsVarLat =
'latitude'
30 obsVarLon =
'longitude'
31 obsVarNormErr =
'dσ\N{SUPERSCRIPT MINUS}\N{SUPERSCRIPT ONE}'
32 obsVarPrs =
'air_pressure'
34 obsVarSCI =
'symmetric_cloud_impact'
35 obsVarSenZen =
'sensor_zenith_angle'
36 obsVarSenAzi =
'sensor_azimuth_angle'
37 obsVarSolZen =
'solar_zenith_angle'
38 obsVarSolAzi =
'solar_azimuth_angle'
40 degree=
u'\N{DEGREE SIGN}'
44 'air_temperature': [
'K',
'T' ],
45 'bending_angle': [
'%',
'Bnd' ],
46 obsVarBT: [
'K',
'BT' ],
47 'eastward_wind': [
'm/s',
'U' ],
48 'northward_wind': [
'm/s',
'V' ],
49 'refractivity': [
'%',
'Ref' ],
50 'specific_humidity': [
'kg/kg',
'qv' ],
51 'surface_pressure': [
'Pa',
'Ps' ],
52 'virtual_temperature': [
'K',
'Tv' ],
53 obsVarAlt: [
'm',
'alt' ],
54 obsVarACI: [
'K',
'ACI' ],
55 obsVarCldFrac: [ miss_s,
'cldfrac' ],
56 obsVarLandFrac: [ miss_s,
'landfrac'],
57 obsVarLat: [ degree,
'lat' ],
58 obsVarLon: [ degree,
'lon' ],
59 obsVarLT: [
'hr', obsVarLT ],
60 obsVarNormErr: [ miss_s, obsVarNormErr ],
61 obsVarPrs: [
'hPa',
'P' ],
62 obsVarQC: [ miss_s, obsVarQC ],
63 obsVarSCI: [
'K',
'SCI' ],
64 obsVarSenZen: [ degree,
'zenith' ],
65 obsVarGlint: [ degree, obsVarGlint ],
70 obsRegionBinVar =
'ObsRegion'
71 varDictObs[obsRegionBinVar] = [miss_s, obsRegionBinVar]
79 qcGroup =
'EffectiveQC'
80 errorGroup =
'EffectiveError'
85 metaGroup =
'MetaData'
95 selfObsValue =
'selfObsValue'
96 selfDepValue =
'selfDepValue'
97 selfHofXValue =
'selfHofXValue'
98 selfQCValue =
'selfQCValue'
99 selfErrorValue =
'selfErrorValue'
100 bgHofXValue =
'bgHofXValue'
102 cldfracMeta =
'cldfracMeta'
103 datetimeMeta =
'datetimeMeta'
107 senzenMeta =
'senzenMeta'
108 senaziMeta =
'senaziMeta'
109 solzenMeta =
'solzenMeta'
110 solaziMeta =
'solaziMeta'
111 landfracGeo =
'landfracGeo'
112 clrskyBTDiag =
'clrskyBTDiag'
117 ObsGroups[selfObsValue] = obsGroup
118 ObsGroups[selfDepValue] = depGroup
119 ObsGroups[selfHofXValue] = hofxGroup
120 ObsGroups[selfQCValue] = qcGroup
121 ObsGroups[selfErrorValue] = errorGroup
123 for key
in ObsGroups.keys():
124 ObsVars[key] = vNameStr
126 ObsGroups[bgHofXValue] = hofxGroup+bgIter
127 ObsVars[bgHofXValue] = vNameStr
130 ObsVars[altMeta] = obsVarAlt
131 ObsVars[cldfracMeta] = obsVarCldFrac
132 ObsVars[datetimeMeta] = obsVarDT
133 ObsVars[latMeta] = obsVarLat
134 ObsVars[lonMeta] = obsVarLon
135 ObsVars[prsMeta] = obsVarPrs
136 ObsVars[senzenMeta] = obsVarSenZen
137 ObsVars[senaziMeta] = obsVarSenAzi
138 ObsVars[solzenMeta] = obsVarSolZen
139 ObsVars[solaziMeta] = obsVarSolAzi
141 for key
in ObsVars.keys():
143 ObsGroups[key] = metaGroup
146 intSufSeparator =
'_'
150 ObsVars[landfracGeo] = obsVarLandFrac
151 ObsGroups[landfracGeo] = geoGroup
153 ObsVars[clrskyBTDiag] = obsVarBTClear+intSufSeparator+vChanStr
154 ObsGroups[clrskyBTDiag] = diagGroup
159 ensemble =
'ensemble'
160 ensSuffixBase =
"&&&mem"
165 return ensSuffixBase+str(member)
170 if "@" in WholeVarGrp:
171 var =
'@'.join(WholeVarGrp.split(
'@')[:-1])
172 grp = WholeVarGrp.split(
'@')[-1]
173 elif "/" in WholeVarGrp:
174 grp = WholeVarGrp.split(
'/')[0]
175 var =
'/'.join(WholeVarGrp.split(
'/')[1:])
185 suf = obsVarName.split(intSufSeparator)[-1]
186 if not pu.isint(suf):
189 obsVarName = intSufSeparator.join(obsVarName.split(intSufSeparator)[:-1])
190 return obsVarName, suf
194 return var+intSufSeparator+str(suf)
200 varAtt = varDictObs.get(dictName,[miss_s,dictName])
201 varShort = varAtt[1]+suf
203 return varShort, varUnits
214 hdfFileFormat =
'hdf'
216 ncFileFormat: varATgroup,
217 hdfFileFormat: groupSLASHvar,
223 for fileFormat, ctor
in IODAVarCtors.items():
224 BaseVars[fileFormat] = {}
225 for baseVar, ObsVar
in ObsVars.items():
226 BaseVars[fileFormat][baseVar] = ctor(ObsVar, ObsGroups[baseVar])
228 def base2dbVar(baseVar, varName, fileFormat, outerIter = None):
230 dbVar = BaseVars[fileFormat][baseVar]
233 dbVar = re.sub(vNameStr,varName,dbVar)
234 dbVar = re.sub(vChanStr,suf,dbVar)
236 if outerIter
is None:
239 iterStr = str(outerIter)
240 for group
in [hofxGroup, errorGroup, qcGroup]:
242 if group
in dbVar.split(
'@')
or group
in dbVar.split(
'/'):
243 dbVar = re.sub(group,group+iterStr,dbVar)
245 if iterStr == bgIter:
246 dbVar = re.sub(depGroup,depbgGroup,dbVar)
248 dbVar = re.sub(depGroup,depanGroup,dbVar)
254 modVarPrs =
'pressure_p'
255 modVarLat =
'latCell'
256 modVarLon =
'lonCell'
257 modVarLev =
'model_level'
259 kgm3 =
'kg/m\N{SUPERSCRIPT THREE}'
263 modVarLev: [ miss_s,
'ModLev'],
264 modVarLat: [ degree,
'lat' ],
265 modVarLon: [ degree,
'lon' ],
266 modVarPrs: [
'Pa',
'PP' ],
267 'pressure': [
'Pa',
'P' ],
268 'q2': [
'g/kg',
'Q2m' ],
269 'qv': [
'g/kg',
'Qv' ],
270 'rho': [ kgm3,
'rho' ],
271 'surface_pressure': [
'Pa',
'Ps' ],
272 't2m': [
'C',
'T2m' ],
273 'temperature': [
'C',
'T' ],
274 'theta': [
'K',
'Theta'],
275 'u': [
'm/s',
'uedge'],
276 'u10': [
'm/s',
'U10m' ],
277 'uReconstructZonal': [
'm/s',
'U' ],
278 'uReconstructMeridional': [
'm/s',
'V' ],
279 'v10': [
'm/s',
'V10m' ],
286 varDictModel[noBinVar] = [miss_s, noBinVar]
288 modelRegionBinVar =
'ModelRegion'
289 varDictModel[modelRegionBinVar] = [miss_s, modelRegionBinVar]
291 modVarNames2d = [
't2m',
'surface_pressure',
'q2',
'u10',
'v10']
292 modVarNames3d = [
'theta',
'temperature',
'rho',
'pressure',
'uReconstructZonal',
'uReconstructMeridional',
'qv',
'w']
297 varAtt = varDictModel.get(dictName,[miss_s,dictName])
298 varShort = varAtt[1]+suf
300 return varShort, varUnits
303 deg2rad = np.pi / np.float(180.0)
304 rad2deg = np.float(180.0) / np.pi
308 varDictAll = deepcopy(varDictObs)
309 for var, desc
in varDictModel.items():
310 if var
not in varDictAll:
311 varDictAll[var] = deepcopy(desc)
313 assert desc[0] == varDictAll[var][0], var+
' units differ between varDictObs and varDictModel'
314 assert desc[1] == varDictAll[var][1], var+
' abbreviation differs between varDictObs and varDictModel'
def modelVarAttributes(var)
def appendSuffix(var, suf)
def base2dbVar(baseVar, varName, fileFormat, outerIter=None)
def splitObsVarGrp(WholeVarGrp)
def groupSLASHvar(var, group)
def varATgroup(var, group)