Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow netcdf output #238

Open
K20shores opened this issue Sep 10, 2024 · 0 comments · May be fixed by #273
Open

Allow netcdf output #238

K20shores opened this issue Sep 10, 2024 · 0 comments · May be fixed by #273
Assignees

Comments

@K20shores
Copy link
Collaborator

K20shores commented Sep 10, 2024

In python, outputting to netcdf is dead simple as long as xarray is installed

import pandas as pd
import xarray as xr

df = pd.read_csv('ouput.csv')
df.set_index(['time']).to_xarray().to_netcdf('output.nc')
ds = df.set_index(['time']).to_xarray()
ds['CONC.ALKNIT'].attrs = {'units': 'mol m-3'}

Acceptance criteria

  • A new command line option --output-format is present.
    • options are csv and netcdf
    • default to csv
    • when the output format is netcdf and the -o option is not provided, write the results into the current directory. Do not print the csv output
  • In netcdf output, units of all species and environmental conditions are added
    • integrated reaction rates (anything with irr_ in the name) have units of mol m-3
    • any attributes of species from the species.json file should be added to the attrs for that species
  • Csv headers include units as an .units, which would close Descriptive output file names or add units to header #143
    • For example, CONC.ALKNIT.mol m-3
  • All output code (csv, netcdf, printing termainl, whatever), is located in one file

Ideas

  • Perhaps conforming to CF conventions could be nice, at least in terms of metadata on the variables like units, name, description, etc.
    • The description could be read from the species.json, as well as any other information stores in the json files
  • Abstract file output to a new function (or class, whatever) that takes in the command line arguments and determines which output format. When going to netcdf, do the extra work of adding units and as much detail as possible to everything
@K20shores K20shores added this to the Sancy's MusicBox Paper milestone Sep 10, 2024
@mwaxmonsky mwaxmonsky self-assigned this Sep 10, 2024
@K20shores K20shores assigned montythind and unassigned mwaxmonsky Oct 28, 2024
@montythind montythind linked a pull request Nov 1, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants