def get_var_names(filename): if use_ncdump: return pync.call_ncdump_varnames(filename) else: rgrp = ncdat(filename) return rgrp.variables.keys() rgrp.close()
def get_run_info(wrfin, stime_str, etime_str): in_rgrp = ncdat(wrfin) xlon = in_rgrp.variables['XLONG'][:] xlat = in_rgrp.variables['XLAT'][:] in_rgrp.close() sdate = dt.datetime.strptime(stime_str, wrf_dt_fmt) edate = dt.datetime.strptime(etime_str, wrf_dt_fmt) return (xlon.min(), xlon.max()), (xlat.min(), xlat.max()), (sdate, edate)
def get_var_values(varnames, filename): if use_ncdump: var_vals = pync.call_ncdump_vals(varnames, filename) else: var_vals = dict() rgrp = ncdat(filename) for var in varnames: var_vals[var] = rgrp.variables[var][:] rgrp.close() return var_vals
def get_moz_info(mozfile): m_rgrp = ncdat(mozfile) lon = m_rgrp.variables['lon'][:] lon[lon>180] -= 360 # MOZBC files give longitude as degrees east (so 200 in MOZ = -160 in WRF) lat = m_rgrp.variables['lat'][:] mdate = m_rgrp.variables['date'][:] mdatesec = m_rgrp.variables['datesec'][:] moz_st_dt = convert_moz_date(mdate[0], mdatesec[0]) moz_end_dt = convert_moz_date(mdate[-1], mdatesec[-1]) return (lon.min(), lon.max()), (lat.min(), lat.max()), (moz_st_dt, moz_end_dt)
def get_moz_info(mozfile): m_rgrp = ncdat(mozfile) lon = m_rgrp.variables['lon'][:] lon[lon > 180] -= 360 # MOZBC files give longitude as degrees east (so 200 in MOZ = -160 in WRF) lat = m_rgrp.variables['lat'][:] mdate = m_rgrp.variables['date'][:] mdatesec = m_rgrp.variables['datesec'][:] moz_st_dt = convert_moz_date(mdate[0], mdatesec[0]) moz_end_dt = convert_moz_date(mdate[-1], mdatesec[-1]) return (lon.min(), lon.max()), (lat.min(), lat.max()), (moz_st_dt, moz_end_dt)