251 Accepts a header object as input, and selects appropriate readgrid function
252 to use for reading in data from the flexpart binary Fortran files.
254 See the :func:`read_grid` for more information on keyword arguments
256 This is the 'V8' version of the function.
265 OPS.npspec_int =
False
271 OPS.decayconstant = 9e6
275 OPS.BinaryFile =
False
289 if H[
'loutstep'] > 0:
299 nspec_ret = OPS.nspec_ret
300 if isinstance(nspec_ret, int):
301 nspec_ret = [nspec_ret]
302 assert iter(nspec_ret),
"nspec_ret must be iterable."
306 if OPS.time_ret
is not None:
308 time_ret = OPS.time_ret
309 if isinstance(time_ret, int) ==
True:
310 time_ret = [time_ret]
315 time_ret = np.arange(len(H.available_dates))
320 get_dates.append(H.available_dates[t])
326 if time_ret
is not None:
327 Warning(
"overwriting time_ret variable, date was requested")
329 if not isinstance(date, list):
330 date = date.strip().split(
',')
333 get_dates.append(H.available_dates[H.available_dates.index(d)])
336 _shout(
"Cannot find date: %s in H['available_dates']\n" % d)
338 if get_dates
is None:
339 raise ValueError(
"Must provide either time_ret or date value.")
342 fd.grid_dates = get_dates[:]
348 prefix = [
'grid_conc_',
'grid_pptv_', \
349 'grid_time_',
'footprint_',
'footprint_total', \
350 'grid_conc_nest_',
'grid_pptv_nest_', \
351 'grid_time_nest_',
'footprint_nest_',
'footprint_total_nest'
354 units = [
'conc',
'pptv',
'time',
'footprint',
'footprint_total']
355 unit_i = units.index(unit)
359 readgrid = _readgridBF
360 OPS.BinaryFile =
True
370 fd.options.update(OPS)
376 for date_i
in range(len(get_dates)):
377 datestring = get_dates[date_i]
382 spec_fid =
'_' + str(s + 1).zfill(3)
385 filename = os.path.join(H[
'pathname'], \
386 prefix[(unit_i) + (H.nested * 5)] + datestring + spec_fid)
391 print "Total footprint"
392 filename = os.path.join(H[
'pathname'], \
393 prefix[(unit_i) + (H.nested * 5)] + spec_fid)
396 if os.path.exists(filename):
397 H.filename = filename
401 inputvars = [
'filename',
'numxgrid',
'numygrid',
402 'zdims',
'numpoint',
'nageclass', \
403 'scaledepo',
'scaleconc',
404 'decayconstant',
'numpointspec']
406 print v,
" ==> ", H[v]
411 gridT, wetgrid, drygrid, itime =
_readgridBF(H, filename)
415 if OPS.npspec_int
is not False:
416 npspec_int = OPS.npspec_int
420 numpointspec = H.numpointspec
422 gridT, wetgrid, drygrid, itime = readgrid(filename, \
423 H.numxgrid, H.numygrid,
424 H.zdims, numpointspec, H.nageclass, \
425 OPS.scaledepo, OPS.scaleconc, H.decayconstant, npspec_int)
428 wet = wetgrid.squeeze()
430 dry = drygrid.squeeze()
432 zplot = gridT[:, :, :, :, 0]
434 zplot = gridT[:, :, :, :, 0]
438 zplot = sumgrid(zplot, gridT, \
443 if H.direction ==
'forward':
459 FLEXDATA[(s, datestring)][
'grid'] = D
461 FLEXDATA[(s, datestring)][
'itime'] = itime
463 FLEXDATA[(s, datestring)][
'shape'] = zplot.shape
465 FLEXDATA[(s, datestring)][
'max'] = zplot.max()
467 FLEXDATA[(s, datestring)][
'min'] = zplot.min()
468 FLEXDATA[(s, datestring)][
'timestamp'] = datetime.datetime.strptime(datestring,
'%Y%m%d%H%M%S')
469 FLEXDATA[(s, datestring)][
'species'] = H[
'species'][s]
470 FLEXDATA[(s, datestring)][
'gridfile'] = filename
471 FLEXDATA[(s, datestring)][
'rel_i'] = rel_i
472 FLEXDATA[(s, datestring)][
'spec_i'] = s
474 FLEXDATA[(s, datestring)][
'wet'] = wet
476 FLEXDATA[(s, datestring)][
'wet'] =
None
479 FLEXDATA[(s, datestring)][
'dry'] = dry
481 FLEXDATA[(s, datestring)][
'dry'] =
None
484 _shout(
'***ERROR: file %s not found! \n' % filename)
487 fd.set_with_dict(FLEXDATA)
491 qind = (nspec_ret[0], fd.grid_dates[0])
492 fd.grid = fd[qind][fd[qind].keys()[0]].grid