snowex_db.interpretation module#

Module for intentional interpretation of data/scenarios. These are often decisions being made about situations that are perhaps not universal but useful in the context of snowex data and creating the database.

snowex_db.interpretation.add_date_time_keys(data, in_timezone=None, out_timezone='UTC')[source]#

Convert string info from a date/time keys in a dictionary to date and time objects and assign it back to the dictionary as date and time

Args:
data: dictionary containing either the keys date/time or two keys date

and time

in_timezone: String representing Pytz valid timezone of the data coming in out_timezone: String representing Pytz valid timezone of the data being returned

Returns:

d: Python Datetime object

snowex_db.interpretation.avg_from_multi_sample(layer, value_type)[source]#

Our database entries sometimes have multiple values. We want to extract those, cast them, average them and return the the value to be used as the main value in the database

e.g.

layer = {density_a: 180, density_b: 200, density_c: nan} result = 190

Args:

layer: layer dictionary (a single entry from a vertical profile) value_type: string labeling type of data were looking for (density, dielectric constant..)

Returns:

result: Nan mean of the values found

snowex_db.interpretation.convert_cardinal_to_degree(cardinal) float[source]#

Converts cardinal directions to degrees. Also removes any / or - that might get used to say between two cardinal directions

e.g. S/SW turns into SSW which is interpreted as halfway between those two directions allowing for 22.5 degree increments.

Args:

Cardinal: Letters representing cardinal direction

Returns:

degrees: Float representing cardinal direction in degrees from north

snowex_db.interpretation.get_InSar_flight_comment(data_name, desc)[source]#

Takes an annotation file dictionary and forms a string for the Insar file to add to the description of the raster entry

If the data is an amplitude file then it only gets a comment like:

overpass duration : Feb 1 2020 2pm MST - Feb 1 2020 3pm MST

If the data is a derived product then we assign both flight durations:

1st overpass duration: Feb 1 2020 2pm MST - Feb 1 2020 3pm MST 2nd overpass duration: Feb 2 2020 2pm MST - Feb 2 2020 3pm MST

Args:

data_name: String name of the data being parsed (e.g. amplitude) desc: descriptor dictionary formed from the annotation file

Returns:

comment: A comment for the database for the uavsar file uploaded

snowex_db.interpretation.is_number(s)[source]#
snowex_db.interpretation.is_point_data(columns)[source]#

Searches the csv column names to see if the data set is point data, which will have latitude or easting in the columns. If it is, return True

Args:

columns: List of dataframe columns

Return:

result: Boolean indicating if the data is point data

snowex_db.interpretation.manage_aspect(info)[source]#

Manages when aspect is recorded in cardinal directions and converts it to a degrees from North float.

Args:

info: Dictionary potentially containing key aspect. Converts cardinal

Returns:

info: Dictionary with any key named aspect converted to a float of degrees from north

snowex_db.interpretation.manage_degree_values(v)[source]#

Handle parsing of degree strings that may have special characters Args:

v: value theoretically a degree

Returns:

snowex_db.interpretation.manage_degrees_keys(info)[source]#

Manages and interprets string values relating to degrees. Removes degrees symbols and interprets key word flat for slope.

Args:
info: Dictionary containing potential degrees entries to be converted

to numbers

Returns:
info: Modificed dictionary containing string numeric representations of keys

aspect and slope_angle

snowex_db.interpretation.manage_utm_zone(info)[source]#

Manage the nuance of having a utm zone string sometimes and then not being in the keys at all. If the utm_zone is in the dictionary then convert it to an integer. Otherwise add with assign None

Args:

info: Dictionary potentially carrying utm_zone

Returns:

info: Dictionary containing utm_zone

snowex_db.interpretation.standardize_depth(depths, desired_format='snow_height', is_smp=False)[source]#

Data that is a function of depth comes in 2 formats. Sometimes 0 is the snow surface, sometimes 0 is the ground. This function standardizes it for each profile. desired_format can be:

snow_height: Zero at the bottom of the data. surface_datum: Zero at the top of the data and uses negative depths

(easier for plotting)

Args:

depths: Pandas series of depths in either format desired_format: string indicating which format the data is in is_smp: Boolean indicating which data this is, if smp then the data is

surface_datum but with positive depths

Returns:

new: