Comparing SSA Instruments#

Goal: Find colocated SSA measurements with more than one instrument and compare by plotting, this is replicating the plot found in the meta.pdf that came with the data

Approach:

  1. Find all sites with SSA data

  2. Isolate the sites with multiple SSA instruments

  3. Plot each site with all its instruments we found

Process#

Step 1: Find all the Sites that have SSA Data#

from snowexsql.db import get_db
from snowexsql.data import LayerData, PointData
from snowexsql.conversions import points_to_geopandas, query_to_geopandas

import geoalchemy2.functions as gfunc
import geopandas as gpd
import matplotlib.pyplot as plt
import pandas as pd

# Connect to the database
db_name = 'db.snowexdata.org/snowex'

engine, session = get_db(db_name, credentials='./credentials.json')

# Grab all the equivalent diameter profiles
qry = session.query(LayerData).filter(LayerData.type == 'specific_surface_area')

df = query_to_geopandas(qry, engine)

# End our database session to avoid hanging transactions
session.close()

# Grab all the sites with equivalent diameter data (set reduces a list to only its unique entries)
sites = df['site_id'].unique()

Step 2: Isolate all the Sites with Multiple SSA Instruments#

# Store all site names that have mulitple SSA instruments
multi_instr_sites = []
instruments = []

for site in sites:

    # Grab all the layers associated to this site
    site_data = df.loc[df['site_id'] == site]

    # Do a set on all the instruments used here
    instruments_used = site_data['instrument'].unique()

    if len(instruments_used) > 1:
        multi_instr_sites.append(site)

# Get a unqique list of SSA instruments that were colocated
instruments = df['instrument'].unique()

Step 3: Plot all SSA profiles at all Multi-Instrumented Sites#