JMMP-Group / nordic-seas-validation

MIT License
0 stars 1 forks source link

Initialize #1

Closed malmans2 closed 2 years ago

malmans2 commented 2 years ago

Here is how we could use the JMMP GWS http:

import os
import pkg_resources
import pooch
import xarray as xr

RAW = pooch.create(
    # Use the default cache folder for the operating system
    path=pooch.os_cache("NORVAL"),
    base_url="https://gws-access.jasmin.ac.uk/public/jmmp/NORVAL/",
    # We'll load it from a file later
    registry=None,
)
# Get registry file from package_data
registry_file = pkg_resources.resource_stream("src", "registry_raw.txt")
# Load this registry file
RAW.load_registry(registry_file)

file_path = RAW.fetch("OSNAP/OSNAP_Gridded_TS_201408_201604_2018.nc")
# Standard use of xarray to load a netCDF file (.nc)
ds = xr.open_dataset(file_path)

I'll add a function so we can just do something like this:

from src import RAW_REGISTRY
from scipy.io import loadmat

file_path = RAW_REGISTRY.fetch("Kogur/all_gridded.mat")
mat = loadmat(file_path)
malmans2 commented 2 years ago

Done. Usage is

from src.registries import RAW
from scipy.io import loadmat

file_path = RAW.fetch("Kogur/all_gridded.mat")
mat = loadmat(file_path)