Welcome to python-readmet documentation!

Module contents

This module conatins functions and objects for handling (mostly reading) less popular or vendor-specific data file formats used in meterology and neighboring sciences.

Submodule akterm

The classes and functions in this category handle files in format “akterm” by German weather service (DWD)

The original columns in dat file specification are:

entry

description

data range

KENN

Kennung für das Datenkollektiv

AK

STA

Stationsnummer

00001-99999

JAHR

Jahr

1800-2999

MON

Monat

1-12

TAG

Tag

1-31

STUN

Stunde

0-23

NULL

0

QDD

Qualitätsbyte (Windrichtung)

0,1,2,9

QFF

Qualitätsbyte (Windgeschwindigkeit)

0,1,2,3,9

DD

Windrichtung

0-360,999

FF

Windgeschwindigkeit

0-999

QQ1

Qualitätsbyte (Wertstatus)

0-5,9

KM

Ausbreitungsklasse nach Klug/Manier

1-7,9

QQ2

Qualitätsbyte (Wertstatus)

0,1,9

HM

Mischungsschichthöhe (m)

0-9999

QQ3

Qualitätsbyte (Wertstatus)

0-5,9

PP QPP

Niederschlag (SYNOP Code) Qualitätsbyte Niederschlag

0-999 0,9

class readmet.akterm.DataFile(file=None, data=None, z0=None, has=None, prec=None)

object class that holds data and metadata of a dmna file

Parameters:
  • file – (optional, string) filename (optionally including path). If missing, an emtpy object is returned

  • data – (optional, padas.DataFrame) timeseries data. Expected format: Time (datetime64) as data index, wind speed in m/s in column FF, winddirection din degrees in column DD, stability class in column KM. Precipitation amount in mm column PP if prec is True.

  • z0 – (optional, float) surface roughness lenght in m. This parameter is only used if data is given. If None or missing, effective anemometer height are set to 0.

  • has – (optional, float) height of the anemometer in m. This parameter is only used if data is given. If missing, 10 m is used.

  • prec – (optional, bool or None) If True file / data contains additional column PP for rain amount in mm. Default to None.

data = None

DataFrame containing the data from the file loaded. The orginal columns KENN, ‘JAHR’, ‘MON’, ‘TAG’, ‘STUN’, ‘NULL’ are not contained in the DataFrame, instead the date and time are given in the index (datetime64).

file = None

name of file loaded into object

get_h_anemo(z0=None)

returns the effective anemometer height(s) from the object

Parameters:

z0 – roughness length for which the effective anemometer height should be determined. If missing, all heights are returned as array

Returns:

effective anemometer height in m

Return type:

float or array

header = None

array containing the header lines as strings

heights = None

effective anemometer heights for each rouchness class in m

load(file)

loads the contents of an akterm file into the object

Parameters:

file – filename (optionally including path). If missing, an emtpy

Returns:

DataFrame with datetime as index, FF in m/s, DD in DEG, an KM Korman/Meixner stability class, columns QDD,QFF,QQ1,QQ1,HM are contained as in the file.

prec = False

file is extended AKTerm Format containing additional columns containing precipitation infromation

set_h_anemo(z0=None, has=None)

sets the effective anemometer height(s) from z0 and has :param z0: roughness length at the site of the wind measurement in m :param has: height of the wind measurement in m.

If None or missing, 10 m is used.

vars = None

Number of variables in file

readmet.akterm.h_eff(z0s, has)

calulate effectice anemometer heights for all roughness-length classes used in asutal2000 :param z0s: roughness length at the site of the wind measurement in m :param has: height of the wind measurement in m :return: list of length 9 containing the nine

effecive anemometer heights

Return type:

list(9)

readmet.akterm.precipitation_from_synop(synop)

calculate precipitation amount from SYNOP code numbers

Parameters

synoppandas.Series or array-like

SYNOP code numbers

Returns

ppandas.Series

precipitation amount in mm

readmet.akterm.precipitation_to_synop(precip)

generate SYNOP code numbers for precipitation amount

Parameters

precippandas.Series or array-like

precipitation amount in mm / observation period

Returns

spandas.Series
SYNOP key PP (precipitation amount):

000 no precipitation 001 1 mm 002 2 mm … … 988 988 mm 989 989 mm or more 990 0.05 mm or less 991 0.1 mm 992 0.2 mm … … 999 0.9 mm

Submodule dmna

The classes and functions in this category handle files in format “DMNA” created by Ingenieurbüro Janicke GbR, Überlingen, Germany (https://www.janicke.de)

The most comprehensive description of this format can be found in the manual to the AUSTAL2000 atmospheric dispersion model [JAN2011].

class readmet.dmna.DataFile(file=None, values=None, axs=None, name=None, types=None, cmpr=False, mode='text', text=False, header_only=False, **kwargs)

object class that holds data and metadata of a dmna file

Parameters:
  • file – filename (optionally including path). If missing, an emtpy object is returned

  • text – (optional) If True the raw file contents are containted as atrribute text in the object. If False or missing, the raw file contents are discarded after parsing.

axes(ax=None)

Return positions of grid lines in model coordinates

Parameters:

ax – (string, optional) name of axis to return. If missing or None, all axes are returned.

Returns:

dict with axis names as keys, containing list(s) of positions as values.

binary = False

if data block is text of binary data

compressed = False

If data block is compressed with gz

data = None

dictionary containing the data from the file loaded. The keys are the variable names. The values are of type pandas.DataFrame with time as index, if the file contains timeseries. The values are of type numpy.array, if the file contains gridded data.

data_file = None

filename if the data block is stored in a separate file

dims = 0

Number of dimensions

file = None

name of file loaded into object

filetype = None

grid or timeseries

grid(what=None)

calculate grid definition needed for georeferencing :returns xlen: number of cells along x-axis :returns ylen: number of cells along x-axis :returns xll: right-ward position of lower left (southwest) corner :returns yll: u-ward position of lower left (southwest) corner :returns delta: grid spacing

header = {}

dictionary containing the dmna header entries as strings

load(file, text=False, header_only=False)

loads the contents of a dmna file into the object

Parameters:
  • file – filename (optionally including path). If missing, an emtpy

  • text – (optional) If True the raw file contents are containted as atrribute text in the object. If False or missing, the raw file contents are discarded after parsing.

  • header_only – (optional) If True skip loading the data. Useful for fast scanning of file headers.

shape = None

Shape of data files in data

text = None

text contents the file loaded with the (decompressed) text contents of an eventual external datfile appended

variables = None

variable names

vars = None

Number of variables in file

write(filename)

Writes DataFile object to file

Parameters:

filename – (string) name of file to write, optionally containing a path.

Submodule scintec1

The classes and functions in this category handle files in format “Scintec FORMAT-1” and “Scintec FORMAT-1.1” created by Scintec AG, Rottenburg, Germany (https://scintec.com)

The most comprehensive description of “FORMAT-1” can be found in the sodar software manual [APRu127] and of “FORMAT-1.1”. in the scintillometer software manual [SRun115].

class readmet.scintec1.DataFile(file=None, text=None)

object class that holds data and metadata of a Scintec-1 file

Parameters:
  • file – filename (optionally including path). If missing, an emtpy object is returned

  • text – (optional) If True the raw file contents are containted as atrribute text in the object. If False or missing, the raw file contents are discarded after parsing.

comments = None

dictionary containing the comments header entries as strings

file = None

name of file loaded into object

header = None

dictionary containing the header entries as strings

nonprofile = None

pandas.Dataframe containing the non-profile data (i.e. scalar timeseries) from the file loaded. The index is time, each column represents one variable.

profile = None

dictonary containing the profile data from the file loaded. The keys are the variable names. The values are of type pandas.DataFrame with time as index, and the measurement levels as columns.

text = None

text contents the file loaded. Also contains the (decompressed) text contents of an eventual external datfile appended to the main file.

vars = None

pandas.Dataframe containing information of the variables The index contains the variable symbol. The columns are “label”,”symbol”,”unit”,”type”,”error_mask”,”gap_value” for each variable.

readmet.scintec1.read(pattern)

read a sequence of Scintec-1 files into one data structue

Parameters:

pattern – a globbing pattern describing one or multiple filenames or paths

Returns:

contained variables as dictionary with variable names as keys. Each variable is returned as a pandas.DataFrame with date/time as index of type pandas.DatetimeIndex

Submodule toa5

The classes and functions in this category handle files in format “TOA5” created by Campbell Scientific (R), Logan, Utah, USA (https://www.campbellsci.com)

The most comprehensive description of this format can be found in the LoggerNet sofatware manual from Campbell Scientific, e.g. Version 4.1 [CS2011].

class readmet.toa5.Header

object class that holds metadate contained in the TOA5 header

can be accessed like dict

readmet.toa5.check_file(filename)

checks is the given file exists, is readable, and is a TOA5 file

Parameters:

filename – file name (optionally including path)

Returns:

True if file is valid TOA5, False else.

Return type:

bool

readmet.toa5.format_field(v: float)

format information in the same way the CampbellScientific software does: 10 decimals below 0.001, 9 decimals below 0.01, 8 decimals below 0.1, 7 decimals below 1.0, 9 significant digits below 10^9, and no decimals above, stripping all trailing zeroes (!) and trailing decimal points (!).

Parameters:

v – number or string to be formatted

Returns:

formatted string

Return type:

str

readmet.toa5.get_data(filename)

extracts data table from the file

Parameters:

filename – file name (optionally including path)

Returns:

data from the file given

Return type:

pandas.DataFrame

readmet.toa5.get_header(filename)

extracts header from the file

Parameters:

filename – file name (optionally including path)

Returns:

header from file given

Return type:

Header

readmet.toa5.getfields(line)

parses a line from the file and splits it into fields

Parameters:

line – file line as string (optionally including a trailing newline)

Returns:

field value(s)

Return type:

list of string

readmet.toa5.read(filename)

extracts header and data from the file

Parameters:

filename – file name (optionally including path)

Returns:

header and data from file given

Return type:

Header and panads.DataFrame

readmet.toa5.write(filename, header, data)

checks, if data and header are consistsnt and then writes header plus data to the file, overwriting any information if the file exists.

Parameters:
  • filename – file name (optionally including path)

  • header – file header information as type Header

  • data – data table as type pandas.DataFrame

readmet.toa5.write_data(file, values)

writes data to the file. Data are appendend to file if file exists, leaving a header or other data in place

Parameters:
  • file – file name (optionally including path)

  • values – data table as type pandas.DataFrame

readmet.toa5.write_file(filename, header, data)

writes header plus data to the file, without further checks, overwriting any information if the file exists.

Parameters:
  • filename – file name (optionally including path)

  • header – file header information as type Header

  • data – data table as type pandas.DataFrame

readmet.toa5.write_header(file, header)

writes header to the file

Parameters:
  • file – file name (optionally including path)

  • header – file header information as type Header

References

[CS2011]

Campbell Scientific LoggerNet Version 4.1 Instruction Manual, Campbell Scientific Ltd, Logan, Utah, USA, 2011

[JAN2011]

Ingenieurbüro Janicke AUSTAL2000 – Programmbeschreibung zu Version 2.5 Umweltbundesamt, Dessau-Roßlau, Umweltbundesamt, Dessau-Roßlau, 2011

[APRu127]

Scintec Sodar Software Manual APRun, Ver.1.27, Scintec AG, Rottenburg, Germany, 2015

[SRun115]

Scintec Scintillometer Software Manual SRun, Ver.1.12, Scintec AG, Rottenburg, Germany, 2015

Indices and tables