2.2. floodestimation.parsers — Parsing FEH data files¶
Parsers for FEH-style data files.
Module contains base parser class and subclassses for parsing CD3 files, AMAX files, etc.
Example:
>>> from floodestimation import parsers
>>> catchment = parsers.Cd3Parser().parse("17002.CD3")
>>> catchment.amax_records = parsers.AmaxParser().parse("17002.AM")
>>> catchment.id
17002
>>> catchment.watercourse
'River Leven'
>>> catchment.descriptors.dtm_area
416.56
>>> catchment.descriptors.centroid_ngr
(317325, 699832)
>>> catchment.amax_records[0].water_year
1968
>>> catchment.amax_records[0].flow
34.995
2.2.1. FehFileParser — Base file parser class¶
-
class
floodestimation.parsers.FehFileParser[source]¶ Generic parser for FEH file format.
File consists typically of multiple sections as follows:
[Section Name] field, value another field, value 1, value 2 [End]
-
object= None¶ Object that will be returned at end of parsing.
-
parse_str(s)[source]¶ Parse string and return relevant object
Parameters: s (str) – string to parse Returns: Parsed object
-
2.2.2. Cd3Parser — Parsing catchment files¶
-
class
floodestimation.parsers.Cd3Parser[source]¶ Bases:
floodestimation.parsers.FehFileParser-
parse(file_name)¶ Parse entire file and return relevant object.
Parameters: file_name (str) – File path Returns: Parsed object
-
parse_feh_date_format(s)¶ Return a date object from a string in FEH date format, e.g. 01 Jan 1970
Parameters: s (str) – Formatted date string Returns: date object Return type: datetime.date
-
parse_str(s)¶ Parse string and return relevant object
Parameters: s (str) – string to parse Returns: Parsed object
-
2.2.3. XmlCatchmentParser — Parsing catchments saved as xml files¶
-
class
floodestimation.parsers.XmlCatchmentParser[source]¶ Parser for XML catchment files as exported from FEH CD-ROM (v3).
An xml schema is not available.
2.2.4. AmaxParser — Parsing annual maximum flow records¶
-
class
floodestimation.parsers.AmaxParser[source]¶ Bases:
floodestimation.parsers.FehFileParser-
parsed_class¶ Class to be returned by
parse(). In this case a list ofAmaxRecordobjects.alias of
list
-
parse(file_name)¶ Parse entire file and return relevant object.
Parameters: file_name (str) – File path Returns: Parsed object
-
parse_feh_date_format(s)¶ Return a date object from a string in FEH date format, e.g. 01 Jan 1970
Parameters: s (str) – Formatted date string Returns: date object Return type: datetime.date
-
parse_str(s)¶ Parse string and return relevant object
Parameters: s (str) – string to parse Returns: Parsed object
-
2.2.5. PotParser — Parsing peaks-over-threshold (POT) records¶
-
class
floodestimation.parsers.PotParser[source]¶ Bases:
floodestimation.parsers.FehFileParser-
parsed_class¶ Class to be returned by
parse(). In this case aPotDatasetobjects.alias of
PotDataset
-
parse(file_name)¶ Parse entire file and return relevant object.
Parameters: file_name (str) – File path Returns: Parsed object
-
parse_feh_date_format(s)¶ Return a date object from a string in FEH date format, e.g. 01 Jan 1970
Parameters: s (str) – Formatted date string Returns: date object Return type: datetime.date
-
parse_str(s)¶ Parse string and return relevant object
Parameters: s (str) – string to parse Returns: Parsed object
-