GEUS-Glaciology-and-Climate / pyNEAD

Python interface for NEAD file format
GNU Lesser General Public License v3.0
1 stars 0 forks source link

nead.write #3

Closed trotsiuk closed 3 years ago

trotsiuk commented 3 years ago

More as a question.

Is there an interest and plan also to have a nead.write function?

BaptisteVandecrux commented 3 years ago

Hi Volodymyr, I made a separate branch with a nead wrtier: https://github.com/GEUS-PROMICE/pyNEAD/tree/write At the moment it asks for what it should put in the header in form of a "ini" text file: https://github.com/GEUS-PROMICE/pyNEAD/blob/write/sample_header.ini

Here is how I use it at the moment:

import pytest
import numpy as np
import nead
fname = "sample.csv"

def test_write():
    ds = nead.read(fname, index_col=0, MKS=True)
    df = ds.to_dataframe()
    df = df.reset_index()
    nead.write(df, nead_config = 'sample_header.ini', output_path = 'sample_out.csv')
    ds2 = nead.read('sample_out.csv', index_col=0, MKS=True)
    print(ds2)

Soon we should make a function that builds the header from the metadata contained in an xarray. Maybe you have been working on it in the meantime?

mankoff commented 3 years ago

Sorry for the silence @trotsiuk. I did not get notified of this issue. @BaptisteVandecrux has just implemented this, it should be pushed to main soon.

trotsiuk commented 3 years ago

Cool, thank you both @BaptisteVandecrux and @mankoff! I haven't been working yet with nead format, but planning to use it in collaboration with @EnviDat.