barronh / pseudonetcdf

PseudoNetCDF like NetCDF except for many scientific format backends
GNU Lesser General Public License v3.0
77 stars 35 forks source link

CAMx file header is not correct once it is generated by pncgen. #37

Closed jaegunjung closed 6 years ago

jaegunjung commented 6 years ago

Hi Barron,

It is a minor issue, but I want to note. When the CAMx file is generated by pncgen, the ending date (iedate) is same as the beginning date (ibdate), and the ending time (etime) is one larger than the beginning time (btime) regardless of how many time stamps the file has. For the variable names in parentheses, I referred the CAMx manual. It says,

name, note, itzon, nvar, ibdate, btime, iedate, etime
plon, ...

In the program (CAMx, preproc, and postproc) that I am exposed, this seems not an issue. But, it may be better the file header correctly reflects what is in the file. To figure out what file attributes are associated with them, I did,

pncdump --head --format=uamiv camxfile.bin

But I cannot find the attributes related to the variables of interest.

Thanks - Jaegun

barronh commented 6 years ago

I do not get the same answer. Maybe a version issue or a method issue.

First, I make two files with varying lengths of times using the CAMx test-case data.

$ pncgen -O --out-format=uamiv -f uamiv CAMx.v6.40.midwest.36.12.noMPI.20020603.avrg.grd01 test.uamiv
$ pncgen -O --out-format=uamiv -f uamiv -s TSTEP,0,3 CAMx.v6.40.midwest.36.12.noMPI.20020603.avrg.grd01 test3.uamiv

Then, use python struct to view the ibdate, btime, iedate, and etime.

$ python -c "import sys; import struct; instring = open('test.uamiv', 'rb').read(312); print(struct.unpack('>i40c240ciiififi', instring)[-5:-1])"
(2154, 0.0, 2155, 0.0)
$ python -c "import sys; import struct; instring = open('test3.uamiv', 'rb').read(312); print(struct.unpack('>i40c240ciiififi'
, instring)[-5:-1])"
(2154, 0.0, 2154, 3.0)

Note that the bdate and edate are not always the same and that the etime is not always larger than btime.

The iedate and etime variables are derived either from ETFLAG or SDATE, STIME, and TSTEP (see PseudoNetCDF/camxfiles/uamiv/Write.py). Make sure ETFLAG is correct.

jaegunjung commented 6 years ago

Hi Barron,

The file, PseudoNetCDF/camxfiles/uamiv/Write.py that I used was different from the file in this github. Mine was generated in early May 2017 while the posted one was in late May 2017. I did followings, and there is no issue any more.

pip uninstall PseudoNetCDF
pip install http://github.com/barronh/pseudonetcdf/archive/master.zip

I may need to do this when I have another issue and see any update in the github in future before I ask.

Thanks - Jaegun