Skip to content

Commit

Permalink
picarro tools for the smochar project
Browse files Browse the repository at this point in the history
  • Loading branch information
hagne committed Feb 27, 2024
1 parent e977588 commit adf797a
Showing 1 changed file with 40 additions and 1 deletion.
41 changes: 40 additions & 1 deletion atmPy/gases/instruments/picarro.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,46 @@
import pathlib as pl
import pandas as pd

def open_file(path, verbose = False):

def open_mobile(p2f=pl.Path('/home/ccg/mund/dev/mobileLabSites/bos/ML_dataManager/output/bos_picarro_60sec_avg.csv')):

df = pd.read_csv(p2f)

# set index
df.index = pd.to_datetime(df.dt,)
df.index.name = 'time'
df.drop('dt', axis=1, inplace=True)

dt = (df.index[1:] - df.index[:-1]).median()

dtunits = ['days', 'hours', 'minutes', 'seconds']

for dfu in dtunits:
# print(getattr(dt, dfu))
dtf = dt / pd.to_timedelta(1, dfu)
if dtf >= 1:
dt_freq = (dtf, dfu)
break

dt_freq

ds = df.to_xarray()

for v in ds.variables:
if v == 'time':
continue
# print(v)
unit = v.split('_')[-1]
ds[v].attrs['unit'] = unit
if v.split('_')[0] == 'avg':
ds[v].attrs['avg'] = dt_freq

ds = ds.rename({v: v.replace('avg', '').replace(unit, '').replace('_', '')})

return Picarro(ds)


def open_prelim(path, verbose = False):
p2f = pl.Path(path)

if p2f.is_file():
Expand Down

0 comments on commit adf797a

Please sign in to comment.