Parser¶
riweather.parser.ISDRecord
pydantic-model
¶
Bases: BaseModel
ISD data record.
Show JSON schema:
{
"$defs": {
"AdditionalData": {
"description": "Additional data section.\n\n!!! warning\n Not yet implemented. Reserved for future use.",
"properties": {},
"title": "AdditionalData",
"type": "object"
},
"AirTemperatureObservation": {
"description": "An observation of current air temperature.",
"properties": {
"temperature_c": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Temperature C"
},
"quality_code": {
"maxLength": 1,
"title": "Quality Code",
"type": "string"
}
},
"required": [
"temperature_c",
"quality_code"
],
"title": "AirTemperatureObservation",
"type": "object"
},
"AtmosphericPressureObservation": {
"description": "An observation of current atmospheric pressure.",
"properties": {
"pressure": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Pressure"
},
"quality_code": {
"maxLength": 1,
"title": "Quality Code",
"type": "string"
}
},
"required": [
"pressure",
"quality_code"
],
"title": "AtmosphericPressureObservation",
"type": "object"
},
"ControlData": {
"description": "Control data section.\n\n!!! usage\n [Control Data](../about/integrated_surface_dataset.md#control-data)",
"properties": {
"total_variable_characters": {
"title": "Total Variable Characters",
"type": "integer"
},
"usaf_id": {
"maxLength": 6,
"minLength": 6,
"pattern": "^\\w*$",
"title": "Usaf Id",
"type": "string"
},
"wban_id": {
"maxLength": 5,
"minLength": 5,
"pattern": "^\\d*$",
"title": "Wban Id",
"type": "string"
},
"dt": {
"format": "date-time",
"title": "Dt",
"type": "string"
},
"data_source_flag": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Data Source Flag"
},
"latitude": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Latitude"
},
"longitude": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Longitude"
},
"report_type_code": {
"anyOf": [
{
"maxLength": 5,
"type": "string"
},
{
"type": "null"
}
],
"title": "Report Type Code"
},
"elevation": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Elevation"
},
"call_letter_id": {
"anyOf": [
{
"maxLength": 5,
"type": "string"
},
{
"type": "null"
}
],
"title": "Call Letter Id"
},
"qc_process_name": {
"maxLength": 4,
"title": "Qc Process Name",
"type": "string"
}
},
"required": [
"total_variable_characters",
"usaf_id",
"wban_id",
"dt",
"data_source_flag",
"latitude",
"longitude",
"report_type_code",
"elevation",
"call_letter_id",
"qc_process_name"
],
"title": "ControlData",
"type": "object"
},
"MandatoryData": {
"description": "Mandatory data section.",
"properties": {
"wind": {
"$ref": "#/$defs/WindObservation"
},
"ceiling": {
"$ref": "#/$defs/SkyConditionObservation"
},
"visibility": {
"$ref": "#/$defs/VisibilityObservation"
},
"air_temperature": {
"$ref": "#/$defs/AirTemperatureObservation"
},
"dew_point": {
"$ref": "#/$defs/AirTemperatureObservation"
},
"sea_level_pressure": {
"$ref": "#/$defs/AtmosphericPressureObservation"
}
},
"required": [
"wind",
"ceiling",
"visibility",
"air_temperature",
"dew_point",
"sea_level_pressure"
],
"title": "MandatoryData",
"type": "object"
},
"SkyConditionObservation": {
"description": "An observation of current sky condition.",
"properties": {
"ceiling_height": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Ceiling Height"
},
"ceiling_quality_code": {
"maxLength": 1,
"title": "Ceiling Quality Code",
"type": "string"
},
"ceiling_determination_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Ceiling Determination Code"
},
"cavok_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Cavok Code"
}
},
"required": [
"ceiling_height",
"ceiling_quality_code",
"ceiling_determination_code",
"cavok_code"
],
"title": "SkyConditionObservation",
"type": "object"
},
"VisibilityObservation": {
"description": "An observation of current sky visibility.",
"properties": {
"distance": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Distance"
},
"distance_quality_code": {
"maxLength": 1,
"title": "Distance Quality Code",
"type": "string"
},
"variability_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Variability Code"
},
"variability_quality_code": {
"maxLength": 1,
"title": "Variability Quality Code",
"type": "string"
}
},
"required": [
"distance",
"distance_quality_code",
"variability_code",
"variability_quality_code"
],
"title": "VisibilityObservation",
"type": "object"
},
"WindObservation": {
"description": "An observation of current wind speed and direction.",
"properties": {
"direction_angle": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Direction Angle"
},
"direction_quality_code": {
"maxLength": 1,
"title": "Direction Quality Code",
"type": "string"
},
"type_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Type Code"
},
"speed_rate": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Speed Rate"
},
"speed_quality_code": {
"maxLength": 1,
"title": "Speed Quality Code",
"type": "string"
}
},
"required": [
"direction_angle",
"direction_quality_code",
"type_code",
"speed_rate",
"speed_quality_code"
],
"title": "WindObservation",
"type": "object"
}
},
"description": "ISD data record.",
"properties": {
"control": {
"$ref": "#/$defs/ControlData"
},
"mandatory": {
"$ref": "#/$defs/MandatoryData"
},
"additional": {
"items": {
"$ref": "#/$defs/AdditionalData"
},
"title": "Additional",
"type": "array"
}
},
"required": [
"control",
"mandatory"
],
"title": "ISDRecord",
"type": "object"
}
Fields:
-
control
(ControlData
) -
mandatory
(MandatoryData
) -
additional
(list[AdditionalData]
)
riweather.parser.ControlData
pydantic-model
¶
Bases: BaseModel
Control data section.
Usage
Show JSON schema:
{
"description": "Control data section.\n\n!!! usage\n [Control Data](../about/integrated_surface_dataset.md#control-data)",
"properties": {
"total_variable_characters": {
"title": "Total Variable Characters",
"type": "integer"
},
"usaf_id": {
"maxLength": 6,
"minLength": 6,
"pattern": "^\\w*$",
"title": "Usaf Id",
"type": "string"
},
"wban_id": {
"maxLength": 5,
"minLength": 5,
"pattern": "^\\d*$",
"title": "Wban Id",
"type": "string"
},
"dt": {
"format": "date-time",
"title": "Dt",
"type": "string"
},
"data_source_flag": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Data Source Flag"
},
"latitude": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Latitude"
},
"longitude": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Longitude"
},
"report_type_code": {
"anyOf": [
{
"maxLength": 5,
"type": "string"
},
{
"type": "null"
}
],
"title": "Report Type Code"
},
"elevation": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Elevation"
},
"call_letter_id": {
"anyOf": [
{
"maxLength": 5,
"type": "string"
},
{
"type": "null"
}
],
"title": "Call Letter Id"
},
"qc_process_name": {
"maxLength": 4,
"title": "Qc Process Name",
"type": "string"
}
},
"required": [
"total_variable_characters",
"usaf_id",
"wban_id",
"dt",
"data_source_flag",
"latitude",
"longitude",
"report_type_code",
"elevation",
"call_letter_id",
"qc_process_name"
],
"title": "ControlData",
"type": "object"
}
Fields:
-
total_variable_characters
(int
) -
usaf_id
(str
) -
wban_id
(str
) -
dt
(datetime
) -
data_source_flag
(str | None
) -
latitude
(float | None
) -
longitude
(float | None
) -
report_type_code
(str | None
) -
elevation
(int | None
) -
call_letter_id
(str | None
) -
qc_process_name
(str
)
Validators:
total_variable_characters
pydantic-field
¶
Total number of characters in the variable length section. The total record length equals 105 plus the value stored in this field.
usaf_id
pydantic-field
¶
United States Air Force (USAF) Master Station Catalog identifier. For United States stations, this is a value between 720000 and 799999.
dt
pydantic-field
¶
The date and time of the observation, based on Coordinated Universal Time (UTC).
data_source_flag
pydantic-field
¶
A flag indicating the source or combination of sources used in creating the observation.
Note
latitude
pydantic-field
¶
The latitude coordinate of the observation. Negative values are located in the southern hemisphere.
longitude
pydantic-field
¶
The longitude coordinate of the observation. Negative values are located in the western hemisphere.
report_type_code
pydantic-field
¶
A flag indicating the type of geophysical surface observation.
Note
elevation
pydantic-field
¶
The elevation of the observation relative to Mean Sea Level, in meters.
qc_process_name
pydantic-field
¶
Quality control process applied to the observation.
Note
parse_datetime
pydantic-validator
¶
Parse dates and times as they appear in ISD to a tz-aware datetime object.
This is a Pydantic validator, users shouldn’t need to call this directly (though they can).
Parameters:
-
value
(Any
) –The portion of the record in the data file corresponding to the date and time fields, characters 16-27. This is always in the form
YYYYMMDDHHMM
.
Returns:
-
datetime
–A timezone-aware datetime object representing the date and time, set to UTC.
Examples:
>>> ControlData.parse_datetime("201809220115")
datetime.datetime(2018, 9, 22, 1, 15, tzinfo=datetime.timezone.utc)
>>> ControlData.parse_datetime("201809310115")
Traceback (most recent call last):
ValueError: day is out of range for month
Source code in src/riweather/parser.py
riweather.parser.MandatoryData
pydantic-model
¶
Bases: BaseModel
Mandatory data section.
Show JSON schema:
{
"$defs": {
"AirTemperatureObservation": {
"description": "An observation of current air temperature.",
"properties": {
"temperature_c": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Temperature C"
},
"quality_code": {
"maxLength": 1,
"title": "Quality Code",
"type": "string"
}
},
"required": [
"temperature_c",
"quality_code"
],
"title": "AirTemperatureObservation",
"type": "object"
},
"AtmosphericPressureObservation": {
"description": "An observation of current atmospheric pressure.",
"properties": {
"pressure": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Pressure"
},
"quality_code": {
"maxLength": 1,
"title": "Quality Code",
"type": "string"
}
},
"required": [
"pressure",
"quality_code"
],
"title": "AtmosphericPressureObservation",
"type": "object"
},
"SkyConditionObservation": {
"description": "An observation of current sky condition.",
"properties": {
"ceiling_height": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Ceiling Height"
},
"ceiling_quality_code": {
"maxLength": 1,
"title": "Ceiling Quality Code",
"type": "string"
},
"ceiling_determination_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Ceiling Determination Code"
},
"cavok_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Cavok Code"
}
},
"required": [
"ceiling_height",
"ceiling_quality_code",
"ceiling_determination_code",
"cavok_code"
],
"title": "SkyConditionObservation",
"type": "object"
},
"VisibilityObservation": {
"description": "An observation of current sky visibility.",
"properties": {
"distance": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Distance"
},
"distance_quality_code": {
"maxLength": 1,
"title": "Distance Quality Code",
"type": "string"
},
"variability_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Variability Code"
},
"variability_quality_code": {
"maxLength": 1,
"title": "Variability Quality Code",
"type": "string"
}
},
"required": [
"distance",
"distance_quality_code",
"variability_code",
"variability_quality_code"
],
"title": "VisibilityObservation",
"type": "object"
},
"WindObservation": {
"description": "An observation of current wind speed and direction.",
"properties": {
"direction_angle": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Direction Angle"
},
"direction_quality_code": {
"maxLength": 1,
"title": "Direction Quality Code",
"type": "string"
},
"type_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Type Code"
},
"speed_rate": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Speed Rate"
},
"speed_quality_code": {
"maxLength": 1,
"title": "Speed Quality Code",
"type": "string"
}
},
"required": [
"direction_angle",
"direction_quality_code",
"type_code",
"speed_rate",
"speed_quality_code"
],
"title": "WindObservation",
"type": "object"
}
},
"description": "Mandatory data section.",
"properties": {
"wind": {
"$ref": "#/$defs/WindObservation"
},
"ceiling": {
"$ref": "#/$defs/SkyConditionObservation"
},
"visibility": {
"$ref": "#/$defs/VisibilityObservation"
},
"air_temperature": {
"$ref": "#/$defs/AirTemperatureObservation"
},
"dew_point": {
"$ref": "#/$defs/AirTemperatureObservation"
},
"sea_level_pressure": {
"$ref": "#/$defs/AtmosphericPressureObservation"
}
},
"required": [
"wind",
"ceiling",
"visibility",
"air_temperature",
"dew_point",
"sea_level_pressure"
],
"title": "MandatoryData",
"type": "object"
}
Fields:
-
wind
(WindObservation
) -
ceiling
(SkyConditionObservation
) -
visibility
(VisibilityObservation
) -
air_temperature
(AirTemperatureObservation
) -
dew_point
(AirTemperatureObservation
) -
sea_level_pressure
(AtmosphericPressureObservation
)
riweather.parser.AdditionalData
pydantic-model
¶
riweather.parser.WindObservation
pydantic-model
¶
Bases: BaseModel
An observation of current wind speed and direction.
Show JSON schema:
{
"description": "An observation of current wind speed and direction.",
"properties": {
"direction_angle": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Direction Angle"
},
"direction_quality_code": {
"maxLength": 1,
"title": "Direction Quality Code",
"type": "string"
},
"type_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Type Code"
},
"speed_rate": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Speed Rate"
},
"speed_quality_code": {
"maxLength": 1,
"title": "Speed Quality Code",
"type": "string"
}
},
"required": [
"direction_angle",
"direction_quality_code",
"type_code",
"speed_rate",
"speed_quality_code"
],
"title": "WindObservation",
"type": "object"
}
Fields:
-
direction_angle
(int | None
) -
direction_quality_code
(str
) -
type_code
(str | None
) -
speed_rate
(float | None
) -
speed_quality_code
(str
)
direction_angle
pydantic-field
¶
The angle, measured in angular degrees in a clockwise direction, between true north and the direction from which the wind is blowing.
direction_quality_code
pydantic-field
¶
Quality status of the reported wind direction angle.
Note
type_code
pydantic-field
¶
Code that denotes the character of the wind observation.
Note
speed_rate
pydantic-field
¶
The rate of horizontal travel of air past a fixed point, in meters per second.
speed_quality_code
pydantic-field
¶
Quality status of the reported wind speed rate.
Note
riweather.parser.SkyConditionObservation
pydantic-model
¶
Bases: BaseModel
An observation of current sky condition.
Show JSON schema:
{
"description": "An observation of current sky condition.",
"properties": {
"ceiling_height": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Ceiling Height"
},
"ceiling_quality_code": {
"maxLength": 1,
"title": "Ceiling Quality Code",
"type": "string"
},
"ceiling_determination_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Ceiling Determination Code"
},
"cavok_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Cavok Code"
}
},
"required": [
"ceiling_height",
"ceiling_quality_code",
"ceiling_determination_code",
"cavok_code"
],
"title": "SkyConditionObservation",
"type": "object"
}
Fields:
-
ceiling_height
(int | None
) -
ceiling_quality_code
(str
) -
ceiling_determination_code
(str | None
) -
cavok_code
(str | None
)
ceiling_height
pydantic-field
¶
The height above ground level (AGL) of the lowest cloud or obscuring phenomena layer aloft with 5/8 or more summation total sky cover, which may be predominantly opaque, or the vertical visibility into a surface-based obstruction.
Note
Unlimited ceiling height coded as 22000
.
ceiling_quality_code
pydantic-field
¶
Quality status of the reported ceiling height.
Note
ceiling_determination_code
pydantic-field
¶
Code that denotes the method used to determine the ceiling.
Note
riweather.parser.VisibilityObservation
pydantic-model
¶
Bases: BaseModel
An observation of current sky visibility.
Show JSON schema:
{
"description": "An observation of current sky visibility.",
"properties": {
"distance": {
"anyOf": [
{
"type": "integer"
},
{
"type": "null"
}
],
"title": "Distance"
},
"distance_quality_code": {
"maxLength": 1,
"title": "Distance Quality Code",
"type": "string"
},
"variability_code": {
"anyOf": [
{
"maxLength": 1,
"type": "string"
},
{
"type": "null"
}
],
"title": "Variability Code"
},
"variability_quality_code": {
"maxLength": 1,
"title": "Variability Quality Code",
"type": "string"
}
},
"required": [
"distance",
"distance_quality_code",
"variability_code",
"variability_quality_code"
],
"title": "VisibilityObservation",
"type": "object"
}
Fields:
-
distance
(int | None
) -
distance_quality_code
(str
) -
variability_code
(str | None
) -
variability_quality_code
(str
)
distance
pydantic-field
¶
The horizontal distance, in meters, at which an object can be seen and identified.
Values greater than 160,000m are entered as 160000
.
distance_quality_code
pydantic-field
¶
Quality status of the reported visibility distance.
Note
variability_code
pydantic-field
¶
Code that denotes whether or not the reported visibility is variable.
Value | Description |
---|---|
N |
Not variable |
V |
Variable |
9 |
Missing |
variability_quality_code
pydantic-field
¶
Quality status of the reported variability code.
Note
riweather.parser.AirTemperatureObservation
pydantic-model
¶
Bases: BaseModel
An observation of current air temperature.
Show JSON schema:
{
"description": "An observation of current air temperature.",
"properties": {
"temperature_c": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Temperature C"
},
"quality_code": {
"maxLength": 1,
"title": "Quality Code",
"type": "string"
}
},
"required": [
"temperature_c",
"quality_code"
],
"title": "AirTemperatureObservation",
"type": "object"
}
Fields:
-
temperature_c
(float | None
) -
quality_code
(str
)
quality_code
pydantic-field
¶
Quality status of the reported temperature.
Note
temperature_f
¶
riweather.parser.AtmosphericPressureObservation
pydantic-model
¶
Bases: BaseModel
An observation of current atmospheric pressure.
Show JSON schema:
{
"description": "An observation of current atmospheric pressure.",
"properties": {
"pressure": {
"anyOf": [
{
"type": "number"
},
{
"type": "null"
}
],
"title": "Pressure"
},
"quality_code": {
"maxLength": 1,
"title": "Quality Code",
"type": "string"
}
},
"required": [
"pressure",
"quality_code"
],
"title": "AtmosphericPressureObservation",
"type": "object"
}
Fields:
-
pressure
(float | None
) -
quality_code
(str
)
quality_code
pydantic-field
¶
Quality status of the reported atmospheric pressure.
Note