usnistgov/h5wasm

Getting the real values?

Fil opened this issue · 2 comments

Fil commented

Hello,

I'm trying to read sea surface temperatures (SST) from the following GOES nc4 file:
https://noaa-goes16.s3.amazonaws.com/ABI-L2-SSTF/2023/013/00/OR_ABI-L2-SSTF-M6_G16_s20230130000205_e20230130059513_c20230130105442.nc

To read the file I can do:

const goes = await fetch(
  "https://noaa-goes16.s3.amazonaws.com/ABI-L2-SSTF/2023/013/00/OR_ABI-L2-SSTF-M6_G16_s20230130000205_e20230130059513_c20230130105442.nc"
)
  .then((response) => response.arrayBuffer())
  .then(async (d) => {
    await h5.FS.writeFile("x", new Uint8Array(d));
    return new hdf5.File("x", "r");
  })

And the contents is:

const sst = goes.get("SST").value; // Uint16Array(29419776) [65535, 65535, 65535, 65535, 65535, 65535, …

But how can I get the actual temperatures? Apparently I need to do a transform such as:

function transformKelvin(x) { return x < 65530 ? x * 0.00244163 + 180 : NaN; }

I'm not sure where I can find these factors (scale, and acceptable range) in the file?

I don't know which factors you need exactly, but a lot of values are saved as attributes on the dataset x:
grafik
You can retrieve them like this:
goes.get("x").attrs["scale_factor"], where x is the dataset you're interested in.

Fil commented

perfect! thank you