era5

ERA5.py

ERA5 IO plugin

This module rquires input files:

  • PLEV.nc:
    all pressure level variables for entire domain (single/multiple CGCs) [time X grid cell X level X variable]
  • SURF.nc:
    all surface variables for entire domain (single/multiple CGCs) [time X grid cell X variable]

This plugin contains methods to:

  • classes for both pressurelevel and surface objects

  • extract coarse grid cell (CGC) based on longitude latitude of station

    or CGC centre

  • convert values to toposcale standard

  • writes single parameter files

  • TopoSCALE standard input:

    • air temperature - K
    • precipitation - mmh*1
    • shortwave Wm**2
    • longwave Wm**2
    • wind - U and V vectors
    • time - iso
    • relative humidity

Example

Initialise new era5 instance:

p=era5.Plev(fp, stat.lat, stat.lon)

Attributes:

Todo:

class era5.Plev(fp, mylat, mylon)[source]

Makes a plev object which is array of all pressure level variables processed to standard toposcale units

Parameters:
  • fp – filepath to concatenated PLEVEL.nc file
  • mylat – latitude of station or grid centre
  • mylon – longitude of station or gride centre

Example

p=Plev(fp) varnames=p.varnames()

addShape()[source]

adds two dimensions of time and levels

addTime()[source]

add time vector and convert to ISO Return datetime objects given numeric time values. The units of the numeric time values are described by the units argument and the calendar keyword. The returned datetime objects represent UTC with no time-zone offset, even if the specified units contain a time-zone offset.

calender options defined here: http://unidata.github.io/netcdf4-python/#netCDF4.num2date

addVar(varname, dat)[source]

rename attribute

extractCgc(var, startIndex, endIndex)[source]

extract variable and cgc (now np array) dimension order: time, level, lat,lon

extractCgc5d(var, member, startIndex, endIndex)[source]

extract variable, ensemble memeber and cgc (now np array) from 5d nc files eg era5 ensemble (extra dimension ensemble ‘number’)

dimension order: time, ensemble, level, lat,lon

getVar(var)[source]

extract variables (remains an nc object)

getVarNames()[source]

# returns list of variables excluding dimension names time, lon,lat, level

class era5.Plev_interp(fp, mylat, mylon)[source]

Makes a plev object which is array of all variables processed to standard toposcale units and interpolated to x, y, z

Parameters:fp – filepath to concatenated PLEVEL.nc file

Example

p=Plev(fp) varnames=p.varnames()

interpCgc(var)[source]

# interp variable and cgc (now np array) !!NOT FINISHED!! Perhaps a different class as here includes z interpolation

class era5.Surf(fp, mylat, mylon)[source]

Makes a plev object which is array of all surface variables processed to standard toposcale units

Parameters:fp – filepath to concatenated PLEVEL.nc file

Example

p=Plev(fp) varnames=p.varnames()

extractCgc(var, startIndex, endIndex)[source]

extract variable and cgc (now np array)

extractCgc4d(var, member, startIndex, endIndex)[source]

extract variable, ensemble memeber and cgc (now np array)from 4d nc files eg era5 ensemble (extra dimension ensemble ‘number’)

dimension order: time, ensemble, lat,lon

gridEle()[source]

compute surface elevation of coarse grid

instRad(step)[source]

Convert SWin from accumulated quantities in J/m2 to instantaneous W/m2 see: https://confluence.ecmwf.int/pages/viewpage.action?pageId=104241513

Parameters:step – timstep in seconds (era5=3600, ensemble=10800)

Note: both EDA (ensemble 3h) and HRES (1h) are accumulated over the timestep and therefore treated here the same. https://confluence.ecmwf.int/display/CKB/ERA5+data+documentation

tp2rate(step)[source]

convert tp from m/timestep (total accumulation over timestep) to rate in mm/h

Parameters:step – timstep in seconds (era5=3600, ensemble=10800)

Note: both EDA (ensemble 3h) and HRES (1h) are accumulated over the timestep and therefore treated here the same. https://confluence.ecmwf.int/display/CKB/ERA5+data+documentation

era5.series_interpolate(time_out, time_in, value_in, cum=False)[source]

Interpolate single time series. Convenience function for usage in scaling kernels. time_out: Array of times [s] for which output is desired. Integer. time_in: Array of times [s] for which value_in is given. Integer. value_in: Value time series. Must have same length as time_in. cum: Is valiable serially cummulative like LWin? Default: False.