Recue Interpolated data from old JLD2

Hi everyone, a couple of years ago a created some interpolated functions with Interpolations.jl and saved then to files in JLD2. I used them a lot back in the day, but trying to load them now (new computer, new OS, new Julia and new packages versions) proves impossible.

I can do

@load "Mantle_Vp.jld"

and get:

┌ Warning: saved type Interpolations.GriddedInterpolation{Float64, 4, Float64, Gridded{Linear}, NTuple{4, Vector{Int64}}} is missing field it in workspace type; reconstructing
└ @ JLD2 ~/.julia/packages/JLD2/ryhNR/src/data/reconstructing_datatypes.jl:164
1-element Vector{Symbol}:

If I type the name of the variable Mantle_Vp I can see all the interpolated data is there, but it is not callable.

julia> Mantle_Vp(100,20000,3.6,8.0)
ERROR: MethodError: objects of type JLD2.ReconstructedTypes.var"##Interpolations.GriddedInterpolation{Float64, 4, Float64, Gridded{Linear}, NTuple{4, Vector{Int64}}}#296" are not callable
 [1] top-level scope
   @ REPL[24]:1

Can I output this to a variable to reinterpolate and resave so I can have access to my data again?

You need to:

  1. Re-create the environment setup you used to create JLD2 file (if you have Project.toml and Manifest.toml files this should be doable relatively easily)
  2. Read the data into Julia in this environment.
  3. Save it in some format that is package-version independent.
  4. Load it back in your current environment setup.
1 Like

Hi, thanks for the help, but I do not have any of the environment information. It was all in my old laptop and it is now formatted.

Any other idea?

If there is a way to evaluate the ReconstructedType it might work, but I cannot find the way.

JLD2 is a subset of hdf5,
so you might be able to inspect the file and load the data (with HDF5),
and from this data instantiate an Interpolations.GriddedInterpolation
or the equivalent in your version of Interpolations.jl ?

Ok this took me somewhere but I am am not well versed in HDF5.

I read the file and I can see the internal structure:

And then I can call the Dataset…


And get:

Then I think read can get the data

A = file[“Mantle_Vp”]
(knots = (var"1" = HDF5.Reference(HDF5.API.hobj_ref_t(0x000000000000149a)), var"2" = HDF5.Reference(HDF5.API.hobj_ref_t(0x000000000000163c)), var"3" = HDF5.Reference(HDF5.API.hobj_ref_t(0x0000000000001b26)), var"4" = HDF5.Reference(HDF5.API.hobj_ref_t(0x0000000000001bb7))), coefs = HDF5.Reference(HDF5.API.hobj_ref_t(0x0000000000001c90)))

From here onwards… I do not know where to go. The knots set of variables are some numbers of my original data, but if i call them I get:


Where can I go from here? :slight_smile:

The warning refers to a specific field Instead of reconstructing from HDF5 data, you might try finding out the last version of Interpolation before the it field was added (e.g. using “blame” on github) and loading the JLD file with that version.


Yes! That Worked! Thanks a lot!