Closed JasperSolt closed 5 months ago
Unfortunately since this branch is undergoing active development, there will be some backward compatibility issues like this. We are working on moving backend global parameters to the python wrapper, and if the parameter structures are different, the package doesn't know if it can use it properly for computation.
In the vast majority of cases it will be easier and safer to regenerate the lightcone, however since I know you are performing large runs there are a few workarounds.
If all you need are the output fields, and you don't need to recompute any boxes, you can load the fields using h5py
like you would any other hdf5 file. If you want the convenience of the LightCone
structure, you can construct your own using the fields.
I've pasted a template below using some py21cmfast you can modify for your own purposes
def read_lc_ignoreparams(lcf):
try:
lightcone = p21c.LightCone.read(lcf)
except:
try:
park, glbls = p21c.LightCone._read_inputs(lcf)
boxk = p21c.LightCone._read_particular(lcf)
#this sets globals to defaults, not consistent with the lightcone but allows us to load different versions
lightcone = p21c.LightCone(**park, **boxk)
logger.warning(f"lightcone {lcf} is likely from a different version and may have the wrong parameter structures")
except:
logger.error(f"could not read lightcone {lcf}")
raise FileExistsError
return lightcone
keep in mind that the parameter structures (lightcone.user_params
etc...) will be incorrect, but you'll still have all the boxes. If you're careful you can also replace the parameter structures manually and re-save so you can load it the normal way.
Thanks a ton. I'll probably just use the older version when opening those boxes for now. If I need to pull a more recent version I can manually go in and delete the keys from the hdf5.
In pulling the latest updates to try and resolve #393 , I now get the following error when I try to load in any lightcones at all: