darothen/xbpch

Error opening BPCH output from ND51b diagnositic

Closed this issue · 2 comments

GC version 13.3.4
ND51b output diagnostic over all lat/long grids.

I'm trying to read in a file using:

import xarray as xr
import xbpch as xb

ds = xb.open_bpchdataset(filename=bpchfile, tracerinfo_file=tinfo_file, diaginfo_file=dinfo_file)

and get the following error, which seems to be related to whether or not the xbpch /uff.py can find the prefix or suffix of a line with a specified format (fmt='i'). I tried toggling my endian input settings, but the default of big endian is the only one that doesn't give me an "OSError: ...This can happen if 'endian' is incorrect" error.

I'm not sure if this is an error in xbpch or if this isn't one of the types of files xbpch is supposed to be able to read or not? Any help would be appreciated!

The error report:

File "c:\users\jhask\onedrive\documents\python\my_functions\gcpy\examples\bpch_to_nc\untitled0.py", line 54, in bpch_to_netcdf
    ds = xb.open_bpchdataset(filename=bpchfile,

  File "C:\Users\jhask\anaconda3\envs\sci\lib\site-packages\xbpch\core.py", line 77, in open_bpchdataset
    store = BPCHDataStore(

  File "C:\Users\jhask\anaconda3\envs\sci\lib\site-packages\xbpch\core.py", line 279, in __init__
    self._bpch._read_header()

  File "C:\Users\jhask\anaconda3\envs\sci\lib\site-packages\xbpch\bpch.py", line 227, in _read_header
    line = self.fp.readline('20sffii')

  File "C:\Users\jhask\anaconda3\envs\sci\lib\site-packages\xbpch\uff.py", line 84, in readline
    prefix_size = self._fix()

  File "C:\Users\jhask\anaconda3\envs\sci\lib\site-packages\xbpch\uff.py", line 77, in _fix
    raise EOFError

EOFError

Hi @jhaskinsPhD, unfortunately I don't actively develop this package anymore. If you can share your sample output I can try to take a quick look and confirm the endianness issue that you mention. I haven't followed GEOS-Chem development for several years but it's possible that recent model changes may have included bpch file outputs that break the conventions used to infer them here. You might want to check with the GEOS-Chem Support Team for more information / insight.

After a lot of digging, I finally turned to GAMAP and as it turns out, my bpch file was corrupt and empty! So there's no issue other than it can't open an empty file! Thanks for the code :)