ec-jrc / pyPoseidon

Framework for Hydrodynamic simulations
https://pyposeidon.readthedocs.io/
European Union Public License 1.2
20 stars 7 forks source link

Add param.nml to the global attributes of the merged netcdf #153

Open pmav99 opened 1 year ago

pmav99 commented 1 year ago

I just checked an ADCIRC output file and its global attributes are like these:

Global attributes:
    :_FillValue = -99999.0
    :model = ADCIRC
    :version = noaa.stofs.2d.glo.v1.1.0r2-19-g38d8d4e
    :grid_type = Triangular
    :description = Shinnecock Inlet V20051108               ! UPTO 32 CHARACTER ALPHANUMERIC RUN D
    :agrid = Shinacock Inlet Coarse Grid
    :rundes = Shinnecock Inlet V20051108               ! UPTO 32 CHARACTER ALPHANUMERIC RUN D
    :runid = ADCIRC V45.08                            ! UPTO 24 CHARACTER ALPANUMERIC RUN ID
    :title = adcirc.org netcdf examples project
    :institution = UNC CH Institute of Marine Sciences
    :source = adcirc.org examples page
    :history = based on Shinnecock Inlet but with netcdf output
    :references = http://adcirc.org/home/documentation/example-problems/shinnecock-inlet-ny-with-t
    :comments = netcdf4 format was used (fully compatible with hdf5)
    :host = adcirc.org
    :convention = CF
    :Conventions = UGRID-0.9.0
    :contact = moghimis@gmail.com
    :creation_date = 2022-12-01 19:50:16  00:00
    :modification_date = 2022-12-01 19:50:16  00:00
    :fort.15 = ==== Input File Parameters (below) ====
    :dt = 2.0
    :ihot = 567
    :ics = 2
    :nolibf = 2
    :nolifa = 2
    :nolica = 1
    :nolicat = 1
    :nwp = 0
    :ncor = 1
    :ntip = 1
    :nws = 17
    :nramp = 1
    :tau0 = 0.005
    :statim = 0.0
    :reftim = 0.0
    :rnday = 14.0
    :dramp = 7.0
    :a00 = 0.35
    :b00 = 0.3
    :c00 = 0.35
    :h0 = 0.05
    :slam0 = -72.43
    :sfea0 = 40.66
    :cf = 0.0025
    :eslm = 5.0
    :cori = 0.0001
    :ntif = 5
    :nbfr = 5

I think it can be useful to have the param.nml contents as netcdf metadata. It shouldn't be too difficult to add this info when we merge the data.

@brey thoughts?

brey commented 6 months ago

just adding the parameters dict gives:

Screenshot 2024-01-21 at 20 40 09

Do you think it's ok?

pmav99 commented 6 months ago

I guess that the difference is that the dictionary is coupled with pyPoseidon, while the param.nml is coupled with schism. Both should work.

On second thought, a potential issue with the dictionary is that if there is a bug or even an update in pyPoseidon the dictionary might not be directly usable. You will need to track the version of pyPoseidon, too, in order to recreate the param.nml. With the param.nml there will be no such problems.

Another option would be to add both files. Metadata are cheap :)

brey commented 6 months ago

You mean add the param.nml as json? How else can you add it?

pmav99 commented 6 months ago

I assume you can add it as a string.