Skip to content

Commit

Permalink
new: nfan reading function
Browse files Browse the repository at this point in the history
  • Loading branch information
hagne committed Jan 15, 2025
1 parent 884fb07 commit cfe7133
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 1 deletion.
3 changes: 2 additions & 1 deletion atmPy/data_archives/NOAA_ESRL_GMD_GRAD/aero/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
from .aero import network
from .aero import network
from .file_io import open_nfan
53 changes: 53 additions & 0 deletions atmPy/data_archives/NOAA_ESRL_GMD_GRAD/aero/file_io.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Wed Jan 15 14:52:06 2025
@author: htelg
"""

import xarray as xr

def open_nfan(fn = '/nfs/iftp/aftp/aerosol/bos/2020/ESRL-GMD-AEROSOL_v1.0_HOUR_BOS_s20200101T000000Z_e20210101T000000Z_c20210214T053935Z.nc'):
'''
Open a standard nfan file. You might have to install h5py for this to work?
Parameters
----------
fn : TYPE, optional
path to file.
Returns
-------
dsall : TYPE
DESCRIPTION.
'''

## time, pressure and temp

ds = xr.open_dataset(fn, group='data')

## light_scattering

dss = xr.open_dataset(fn, group='data/light_scattering')
dss = dss.assign_coords({'time': ds.time})#xr.open_dataset(fn, group='data').time})
dss = dss.rename({'wavelength': 'wl_neph'})

# particle_concentration

dspc = xr.open_dataset(fn, group='data/particle_concentration')
dspc = dspc.assign_coords({'time': ds.time})
dspc = dspc.drop_vars(['sample_pressure','sample_temperature']) #They interfer with same variable in scattering, also they both were empty in my test file

## Absorbtion

dsa = xr.open_dataset(fn, group='data/light_absorption')
dsa = dsa.assign_coords({'time': ds.time})
dsa = dsa.rename({'wavelength': 'wl_clap'})

## merge

dsall = xr.merge([dss, dsa, dspc])

return dsall

0 comments on commit cfe7133

Please sign in to comment.