earthkit icon indicating copy to clipboard operation
earthkit copied to clipboard

transform inputs to sub-packages

Open EddyCMWF opened this issue 2 years ago • 3 comments

Is your feature request related to a problem? Please describe.

I'm always frustrated that I have to change the format of my data when calling a method from a sub-package.

Describe the solution you'd like

I'd like the input-objects to be automatically transformed to the correct type by earthkit, usinng the functionality that is available in earthkit-data.

Describe alternatives you've considered

No response

Additional context

Implementation will require knowledge of the data formats required by the sub-package methods. This can be inspected using:

  1. Type-setting
  2. Consistant signitures in variable names, e.g. data = np.ndarray and dataarray = xr.DataArray
  3. Bespoke setting at the function level

For efficient code implementation, it is probably best to use function wrappers instead of decorators. Decorators would require code additions for all functions in the sub-package, whereas a wrapped can be applied programatically. Negative aspect is it may be slower at importing.

Organisation

ECMWF

EddyCMWF avatar Jun 27 '23 07:06 EddyCMWF

Hi @EddyCMWF , I saw your work in branch 6-transform-inputs-to-sub-packages but I am not sure this should be done in theearthkit repo itself. In my opinion earthkitshould not contain any Python code apart from simply importing the components. Besides, components should not depend on the existence of earthkit since we should be able to install them independently. Is it not possible to achieve what you want in one of the components that the others would use?

sandorkertesz avatar Jun 29 '23 07:06 sandorkertesz

Maybe we could consider making a earthkit-utils ?

tlmquintino avatar Jun 30 '23 07:06 tlmquintino

Oh, I just created this issue in earthkit-data: https://github.com/ecmwf/earthkit-data/issues/134 .

I think it may be good to put it in there (for now at least) as it is all based on using earthkit-data to do the conversions.

EddyCMWF avatar Jun 30 '23 09:06 EddyCMWF