Skip to content
euroargodevPublic

About

A Python library to generate Sprof files

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

12 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

⚠️ Work in progress, not ready for production.

Sprof generator in Python

This tool is a Python implementation of matsprof, a stand-alone version of the "nc_create_synthetic_profile" tool used at the Coriolis GDAC to generate mono-cycle synthetic profile (S-PROF) files (from C and B mono-cycle (C-PROF and B-PROF) files).

See http://doi.org/10.13155/55637 for details.

This module will be available in January 2027.

API Design

Argopy integration

output_dir is a specified, only the xr.Dataset is return, otherwise netcdf file is created on disk.

import argopy as ar

af = ar.ArgoFloat(6903091)

# Create the mono cycle in memory synthetic profiles: 
sprofs = af.sprof(cyc: int | List[int])

# output object is a dict of xarray datasets. 
type(sprofs) = SProfObject()
sprofs.monodata = {1: xr.Dataset (cycle 1), ..., N: xr.Dataset (cycle N)}

# multifile dataset can be generated using concat
sprofs.concat() : xr.Dataset # concatenated mono into multi cycle dataset
sprof.multidata = xr.Dataset 

# export to netcdf is a method of the result object 
sprofs.to_netcdf()
sprofs.concat().to_netcdf(Optional[output_dir]: Path = None)

Standalone library

from pysprof import sprof

# Create the in memory synthetic profiles: 
sprofs = sprof(wmo_input_dir: Path,  # Source dir for core and B mono-profile files : needs to follow Argo tree storage
                meta_wmo_input_store: Optional[Path] | xr.Dataset = None, # overrides source dir for meta file
                core_wmo_input_store: Optional[Path] | xr.Dataset = None, # overrides source dir for core files
                b_wmo_input_store: Optional[Path] | xr.Dataset = None, # overrides source dir for B files
                )

'''
wmo_input_dir must respect the GDAC tree storage like: 

/<WMO>
  |  <wmo>_meta.nc 
  |  /profiles
    | B#<wmo>_<cyc>#.nc
    |  #<wmo>_<cyc>#.nc
    | S#<wmo>_<cyc>#.nc

'''
# output object is a dict of xarray datasets. 
type(sprofs) = SProfObject()
sprofs.monodata = {1: xr.Dataset (cycle 1), ..., N: xr.Dataset (cycle N)}

# multifile dataset can be generated using concat
sprofs.concat() : xr.Dataset # concatenated mono into multi cycle dataset
sprof.multidata = xr.Dataset 

# multifile dataset can be generated using concat on already Sprof data
sprofs.concat() : xr.Dataset # concatenated mono into multi cycle dataset
sprof.multidata = xr.Dataset 

# export to netcdf is a method of the result object 
sprofs.to_netcdf()
sprofs.concat().to_netcdf(Optional[output_dir]: Path = None)


# multifile dataset can be generated using monoprofiles already generated 
sprof.concat(wmo_sprof_input_dir: Optional[Path] = None): xr.Dataset # concatenated mono into multi cycle dataset
sprof.multidata = xr.Dataset 

As a cli:

# multi-profile:
sprof make --src="/path/gdac/coriolis/6903091" --dest="/my_floats/WMO/6903091"

# mono:
sprof make --src="/path/gdac/coriolis/6903091" --dest="/my_floats/WMO/6903091/profiles"

About

A Python library to generate Sprof files

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors