Giter Site home page Giter Site logo

Comments (6)

coroa avatar coroa commented on May 22, 2024 1

Fine, then I'll just re-raise the MergeError exception from xarray and we'll leave it at that, that is at least more descriptive than what you get now.

from atlite.

coroa avatar coroa commented on May 22, 2024

I think this is fixed by commit 193164d. I'd appreciate if you could test!

from atlite.

euronion avatar euronion commented on May 22, 2024

I think this is fixed by commit 193164d. I'd appreciate if you could test!

Here is the result

WARNING:atlite.utils:
Found an old-style directory-like cutout. It can manually be recreated using

cutout = atlite.Cutout("../cutouts/western-asia-2016-era5.nc",
                       module="era5",
                       time=slice("2016-01", "2016-12"),
                       x=slice(24.899999618530273, 64.19999694824219),
                       y=slice(44.099998474121094, 10.800000190734863)
cutout.prepare()

but we are trying to offer an automated migration as well ...

WARNING:atlite.utils:Automatic migration failed. Re-create the cutout with the command above!

---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-8-96088e8e5a64> in <module>
      5                     x=slice(25,64),
      6                     y=slice(44,11),
----> 7                     time="2016"
      8 )

~/miniconda/envs/atlite-v0.2/lib/python3.7/site-packages/atlite/cutout.py in __init__(self, name, data, cutout_dir, **cutoutparams)
     92             elif os.path.isdir(os.path.join(self.cutout_dir, self.name)):
     93                 data = utils.migrate_from_cutout_directory(os.path.join(self.cutout_dir, self.name),
---> 94                                                            self.name, self.cutout_fn, cutoutparams)
     95                 self.is_view = True
     96             else:

~/miniconda/envs/atlite-v0.2/lib/python3.7/site-packages/atlite/utils.py in migrate_from_cutout_directory(old_cutout_dir, name, cutout_fn, cutoutparams)
     85             logger.warning("Automatic migration failed. Re-create the cutout with the command above!")
     86 
---> 87     data.attrs['prepared_features'] = list(sys.modules['atlite.datasets.' + data.attrs["module"]].features)
     88 
     89     return data

UnboundLocalError: local variable 'data' referenced before assignment

I think the warning offered is helpful enough and provides all the commands a user needs to quickly get back into the game.
Providing a unprepared cutout instead is I think not a good solution:
Either the loading of the prepared cutout fails (preferred) or succeeds.
But importing a prepared cutout and recieving an unprepared cutout is not what I would expect as a user.

Maybe just throw an additional exception when the automigration / merging fails?

from atlite.

coroa avatar coroa commented on May 22, 2024

One must say, you do have a peculiar cutout there, with time-dependent roughness value in one month and an independent one in another?

MergeError: conflicting values for variable 'roughness' on objects to be combined:
first value: <xarray.Variable (y: 112, x: 132)>
dask.array<shape=(112, 132), dtype=float32, chunksize=(112, 132)>
Attributes:
    units:      m
    long_name:  Forecast surface roughness
second value: <xarray.Variable (time: 8784, y: 112, x: 132)>
dask.array<shape=(8784, 112, 132), dtype=float32, chunksize=(1440, 112, 132)>
Attributes:
    units:      m
    long_name:  Forecast surface roughness

from atlite.

euronion avatar euronion commented on May 22, 2024

Sorry to disappoint, but except for one details that is just a standard cutout downloaded with the cdsapi via the era5.py module. No time indepdendent/dependent roughness there:

> for dspath in pathlib.Path("../cutouts/western-asia-2016-era5/").glob("2016*.nc"):
>   with xr.open_dataset(dspath) as ds:
>       print(dspath,":", "time" in ds.roughness.coords, ds.roughness.size)

../cutouts/western-asia-2016-era5/201601.nc :  False 14784
../cutouts/western-asia-2016-era5/201602.nc :  False 14784
../cutouts/western-asia-2016-era5/201603.nc :  False 14784
../cutouts/western-asia-2016-era5/201604.nc :  False 14784
../cutouts/western-asia-2016-era5/201605.nc :  False 14784
../cutouts/western-asia-2016-era5/201606.nc :  False 14784
../cutouts/western-asia-2016-era5/201607.nc :  False 14784
../cutouts/western-asia-2016-era5/201608.nc :  False 14784
../cutouts/western-asia-2016-era5/201609.nc :  False 14784
../cutouts/western-asia-2016-era5/201610.nc :  False 14784
../cutouts/western-asia-2016-era5/201611.nc :  False 14784
../cutouts/western-asia-2016-era5/201612.nc :  False 14784

from atlite.

coroa avatar coroa commented on May 22, 2024

Ok, I don't understand the MergeError output then, but it also does not matter too much, anyway.

from atlite.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.