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 #4

Closed BaptisteVandecrux closed 3 years ago

BaptisteVandecrux commented 3 years ago

nead file writer developed by Derek and Rebecca at the moment it needs to be given as input a "ini" text file that contains basically the nead header without the '#'

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)

Later on we can make a routine that builds the ini file from the metadata contained in a xarray or dataframe