metloom package¶
Subpackages¶
- metloom.pointdata package
- Submodules
- metloom.pointdata.base module
PointDataPointData.ALLOWED_VARIABLESPointData.DATASOURCEPointData.EXPECTED_COLUMNSPointData.EXPECTED_INDICESPointData.ITERATOR_CLASSPointData.NON_VARIABLE_COLUMNSPointData.POINTS_FROM_GEOM_DEFAULTSPointData.get_daily_data()PointData.get_hourly_data()PointData.get_snow_course_data()PointData.metadataPointData.points_from_geometry()PointData.tzinfoPointData.validate_sensor_df()
PointDataCollection
- metloom.pointdata.cdec module
CDECPointDataCDECPointData.ALLOWED_VARIABLESCDECPointData.CDEC_URLCDECPointData.DATASOURCECDECPointData.META_URLCDECPointData.get_daily_data()CDECPointData.get_event_data()CDECPointData.get_hourly_data()CDECPointData.get_snow_course_data()CDECPointData.is_only_monthly()CDECPointData.is_only_snow_course()CDECPointData.is_partly_snow_course()CDECPointData.points_from_geometry()
- metloom.pointdata.mesowest module
MesowestPointDataMesowestPointData.ALLOWED_VARIABLESMesowestPointData.DATASOURCEMesowestPointData.MESO_URLMesowestPointData.META_URLMesowestPointData.NO_DATA_MESSAGEMesowestPointData.POINTS_FROM_GEOM_DEFAULTSMesowestPointData.create_token_json()MesowestPointData.get_daily_data()MesowestPointData.get_hourly_data()MesowestPointData.get_token()MesowestPointData.points_from_geometry()MesowestPointData.token
- metloom.pointdata.snotel module
- metloom.pointdata.snotel_client module
- metloom.pointdata.usgs module
- Module contents
CDECPointDataCDECPointData.ALLOWED_VARIABLESCDECPointData.CDEC_URLCDECPointData.DATASOURCECDECPointData.META_URLCDECPointData.get_daily_data()CDECPointData.get_event_data()CDECPointData.get_hourly_data()CDECPointData.get_snow_course_data()CDECPointData.is_only_monthly()CDECPointData.is_only_snow_course()CDECPointData.is_partly_snow_course()CDECPointData.points_from_geometry()
MesowestPointDataMesowestPointData.ALLOWED_VARIABLESMesowestPointData.DATASOURCEMesowestPointData.MESO_URLMesowestPointData.META_URLMesowestPointData.NO_DATA_MESSAGEMesowestPointData.POINTS_FROM_GEOM_DEFAULTSMesowestPointData.create_token_json()MesowestPointData.get_daily_data()MesowestPointData.get_hourly_data()MesowestPointData.get_token()MesowestPointData.points_from_geometry()MesowestPointData.token
PointDataPointData.ALLOWED_VARIABLESPointData.DATASOURCEPointData.EXPECTED_COLUMNSPointData.EXPECTED_INDICESPointData.ITERATOR_CLASSPointData.NON_VARIABLE_COLUMNSPointData.POINTS_FROM_GEOM_DEFAULTSPointData.get_daily_data()PointData.get_hourly_data()PointData.get_snow_course_data()PointData.metadataPointData.points_from_geometry()PointData.tzinfoPointData.validate_sensor_df()
PointDataCollectionSnotelPointDataUSGSPointData
Submodules¶
metloom.cli module¶
Console script for metloom.
metloom.dataframe_utils module¶
- metloom.dataframe_utils.append_df(df: Optional[DataFrame], new_df: Optional[DataFrame])[source]¶
append 2 dfs handling Nones Args:
df: optional dataframe new_df: optional dataframe
- Returns:
dataframe or None
- metloom.dataframe_utils.join_df(df: Optional[DataFrame], new_df: Optional[DataFrame], how='left', on=None, filter_unused=False)[source]¶
join two dataframes handling None Args:
df: optional dataframe new_df: optional dataframe how: method for merging on: optional kwarg for DataFrame.join filter_unused: boolean, whether to filter out columns with _unused in
then name
- Returns:
The joined dataframes. This method prefers values from the first if columns are overlapping and renames the overlapping values from the new_df to <column>_unused
- metloom.dataframe_utils.merge_df(df: Optional[DataFrame], new_df: Optional[DataFrame], how='left')[source]¶
join two dataframes. Assumes the dataframes are indexed on datetime Args:
df: optional dataframe new_df: optional dataframe
- Returns:
The merged dataframe
- metloom.dataframe_utils.resample_df(raw_df: DataFrame, variable: SensorDescription, interval: str = 'H')[source]¶
Resample an datatime indexed pandas dateframe to hourly or daily timer intervals. Resample a datetime indexed pandas dataframe for 1 variable
- Args:
- raw_df: Pandas Dataframe containing a datetime index at an interval
smaller than hourly.
variable: SensorDescriptions to be found in the dataframe interval: Interval to resample to. Options are H = Hourly, D=Daily
- Returns:
- df: Pandas Dataframe of a single variable resampled to the
desired interval
- metloom.dataframe_utils.resample_whole_df(raw_df: DataFrame, variable: SensorDescription, interval: str = 'H')[source]¶
Resample an datatime indexed pandas dateframe to hourly or daily timer intervals. Resample a datetime indexed pandas dataframe for 1 variable Other columns get resampled with the .first() values
- Args:
- raw_df: Pandas Dataframe containing a datetime index at an interval
smaller than hourly.
variable: SensorDescriptions to be found in the dataframe interval: Interval to resample to. Options are H = Hourly, D=Daily
- Returns:
- df: Pandas Dataframe of a single variable resampled to the
desired interval
metloom.request_utils module¶
Taken from stackoverflow.com/questions/15445981/how-do-i-disable-the-security-certificate-check-in-python-requests This is necessary to make requests to Snotel without exceptions as we are not able to do the SSL verification
metloom.variables module¶
- class metloom.variables.CdecStationVariables[source]¶
Bases:
VariableBaseAvailable sensors from CDEC. Exhaustive list: http://cdec4gov.water.ca.gov/reportapp/javareports?name=SensList
- PRECIPITATION = SensorDescription(code='45', name='PRECIPITATION', description='PRECIPITATION, INCREMENTAL', accumulated=True)¶
- PRECIPITATIONACCUM = SensorDescription(code='2', name='ACCUMULATED PRECIPITATION', description='PRECIPITATION, ACCUMULATED', accumulated=False)¶
- RH = SensorDescription(code='12', name='Relative Humidity', description='RELATIVE HUMIDITY', accumulated=False)¶
- SNOWDEPTH = SensorDescription(code='18', name='SNOWDEPTH', description='SNOW DEPTH', accumulated=False)¶
- SOLARRAD = SensorDescription(code='103', name='SOLAR RADIATION', description='SOLAR RADIATION', accumulated=False)¶
- SWE = SensorDescription(code='3', name='SWE', description='SNOW, WATER CONTENT', accumulated=False)¶
- TEMP = SensorDescription(code='4', name='AIR TEMP', description='TEMPERATURE, AIR', accumulated=False)¶
- TEMPAVG = SensorDescription(code='30', name='AVG AIR TEMP', description='TEMPERATURE, AIR AVERAGE', accumulated=False)¶
- TEMPGROUND = SensorDescription(code='52', name='GROUND TEMPERATURE INT', description='GROUND TEMPERATURE SNOW/SOIL INTERFACE', accumulated=False)¶
- TEMPGROUND100CM = SensorDescription(code='196', name='GROUND TEMPERATURE -100CM', description='GROUND TEMPERATURE OBS -100CM', accumulated=False)¶
- TEMPGROUND25CM = SensorDescription(code='194', name='GROUND TEMPERATURE -25CM', description='GROUND TEMPERATURE OBS -25CM', accumulated=False)¶
- TEMPGROUND50CM = SensorDescription(code='195', name='GROUND TEMPERATURE -50CM', description='GROUND TEMPERATURE OBS -50CM', accumulated=False)¶
- TEMPMAX = SensorDescription(code='31', name='MAX AIR TEMP', description='TEMPERATURE, AIR MAXIMUM', accumulated=False)¶
- TEMPMIN = SensorDescription(code='32', name='MIN AIR TEMP', description='TEMPERATURE, AIR MINIMUM', accumulated=False)¶
- WINDDIR = SensorDescription(code='10', name='WIND DIRECTION', description='WIND DIRECTION', accumulated=False)¶
- WINDSPEED = SensorDescription(code='9', name='WIND SPEED', description='WIND SPEED', accumulated=False)¶
- class metloom.variables.MesowestVariables[source]¶
Bases:
VariableBaseAvailable sensors from Mesowest There are a lot of variables here. Feel free to PR to add some https://developers.synopticdata.com/mesonet/v2/api-variables/
- DEWPOINT = SensorDescription(code='dew_point_temperature', name='DEW POINT TEMPERATURE', description=None, accumulated=False)¶
- NETLONGWAVE = SensorDescription(code='net_radiation_lw', name='NET LONGWAVE RADIATION', description=None, accumulated=False)¶
- NETSHORTWAVE = SensorDescription(code='net_radiation_sw', name='NET SHORTWAVE RADIATION', description=None, accumulated=False)¶
- PRESSURE = SensorDescription(code='pressure', name='PRESSURE', description=None, accumulated=False)¶
- RH = SensorDescription(code='relative_humidity', name='RELATIVE HUMIDITY', description=None, accumulated=False)¶
- SNOWDEPTH = SensorDescription(code='snow_depth', name='SNOWDEPTH', description=None, accumulated=False)¶
- SOILTEMP = SensorDescription(code='soil_temp', name='SOIL TEMPERATURE', description=None, accumulated=False)¶
- SOILTEMPIR = SensorDescription(code='soil_temp_ir', name='SOIL TEMPERATURE IR', description=None, accumulated=False)¶
- SOLARRADIATION = SensorDescription(code='solar_radiation', name='SOLAR RADIATION', description=None, accumulated=False)¶
- STREAMFLOW = SensorDescription(code='stream_flow', name='STREAMFLOW', description=None, accumulated=False)¶
- SWE = SensorDescription(code='snow_water_equiv', name='SWE', description=None, accumulated=False)¶
- TEMP = SensorDescription(code='air_temp', name='AIR TEMP', description=None, accumulated=False)¶
- WETBULBTEMPERATURE = SensorDescription(code='wet_bulb_temperature', name='WET BULB TEMPERATURE', description=None, accumulated=False)¶
- WINDDIRECTION = SensorDescription(code='wind_direction', name='WIND DIRECTION', description=None, accumulated=False)¶
- WINDSPEED = SensorDescription(code='wind_speed', name='WIND SPEED', description=None, accumulated=False)¶
- class metloom.variables.SensorDescription(code: str = '-1', name: str = 'basename', description: Optional[str] = None, accumulated: bool = False)[source]¶
Bases:
objectdata class for describing a snow sensor
- accumulated: bool = False¶
- code: str = '-1'¶
- description: str = None¶
- name: str = 'basename'¶
- class metloom.variables.SnotelVariables[source]¶
Bases:
VariableBaseAvailable sensors from SNOTEL
- PRECIPITATION = SensorDescription(code='PRCPSA', name='PRECIPITATION', description='PRECIPITATION INCREMENT SNOW-ADJUSTED', accumulated=False)¶
- PRECIPITATIONACCUM = SensorDescription(code='PREC', name='ACCUMULATED PRECIPITATION', description='PRECIPITATION ACCUMULATION', accumulated=False)¶
- RH = SensorDescription(code='RHUMV', name='RELATIVE HUMIDITY', description='RELATIVE HUMIDITY', accumulated=False)¶
- SNOWDEPTH = SensorDescription(code='SNWD', name='SNOWDEPTH', description=None, accumulated=False)¶
- SOILMOISTURE20IN = SensorDescription(code='SMS', name='SOIL MOISTURE -20IN', description='SOIL MOISTURE PERCENT -20IN', accumulated=False)¶
- SOILMOISTURE2IN = SensorDescription(code='SMS', name='SOIL MOISTURE -2IN', description='SOIL MOISTURE PERCENT -2IN', accumulated=False)¶
- SOILMOISTURE4IN = SensorDescription(code='SMS', name='SOIL MOISTURE -4IN', description='SOIL MOISTURE PERCENT -4IN', accumulated=False)¶
- SOILMOISTURE8IN = SensorDescription(code='SMS', name='SOIL MOISTURE -8IN', description='SOIL MOISTURE PERCENT -8IN', accumulated=False)¶
- STREAMVOLUMEADJ = SensorDescription(code='SRVOX', name='STREAM VOLUME ADJ', description='STREAM VOLUME ADJ', accumulated=False)¶
- STREAMVOLUMEOBS = SensorDescription(code='SRVO', name='STREAM VOLUME OBS', description='STREAM VOLUME OBS', accumulated=False)¶
- SWE = SensorDescription(code='WTEQ', name='SWE', description=None, accumulated=False)¶
- TEMP = SensorDescription(code='TOBS', name='AIR TEMP', description=None, accumulated=False)¶
- TEMPAVG = SensorDescription(code='TAVG', name='AVG AIR TEMP', description='AIR TEMPERATURE AVERAGE', accumulated=False)¶
- TEMPGROUND20IN = SensorDescription(code='STO', name='GROUND TEMPERATURE -20IN', description='GROUND TEMPERATURE OBS -20IN', accumulated=False)¶
- TEMPGROUND2IN = SensorDescription(code='STO', name='GROUND TEMPERATURE -2IN', description='GROUND TEMPERATURE OBS -2IN', accumulated=False)¶
- TEMPGROUND4IN = SensorDescription(code='STO', name='GROUND TEMPERATURE -4IN', description='GROUND TEMPERATURE OBS -4IN', accumulated=False)¶
- TEMPGROUND8IN = SensorDescription(code='STO', name='GROUND TEMPERATURE -8IN', description='GROUND TEMPERATURE OBS -8IN', accumulated=False)¶
- TEMPMAX = SensorDescription(code='TMAX', name='MAX AIR TEMP', description='AIR TEMPERATURE MAXIMUM', accumulated=False)¶
- TEMPMIN = SensorDescription(code='TMIN', name='MIN AIR TEMP', description='AIR TEMPERATURE MINIMUM', accumulated=False)¶
- class metloom.variables.USGSVariables[source]¶
Bases:
VariableBaseTo add more sensors: https://help.waterdata.usgs.gov/codes-and-parameters/parameters
- DISCHARGE = SensorDescription(code='00060', name='DISCHARGE', description='DISCHARGE (CFS)', accumulated=False)¶
- STREAMFLOW = SensorDescription(code='74082', name='STREAMFLOW', description='STREAMFLOW, DAILY VOLUME (AC-FT)', accumulated=False)¶
- class metloom.variables.VariableBase[source]¶
Bases:
objectBase class to store all variables for a specific datasource. Each datasource should implement the class. The goal is that the variables are synonymous across implementations.(i.e. PRECIPITATION should have the same meaning in each implementation). Additionally, variables with the same meaning should have the same name attribute of the SensorDescription. This way, if multiple datsources are used to sample the same variable, they can be written to the same column in a csv.
Variables in this base class should ideally be implemented by all classes and cannot be directly used from the base class.
- PRECIPITATION = SensorDescription(code='-1', name='basename', description=None, accumulated=False)¶
- SNOWDEPTH = SensorDescription(code='-1', name='basename', description=None, accumulated=False)¶
- SWE = SensorDescription(code='-1', name='basename', description=None, accumulated=False)¶
Module contents¶
Top-level package for metloom.