metno / esd

An R-package designed for climate and weather data analysis, empirical-statistical downscaling, and visualisation.
87 stars 30 forks source link

combine: combining more than two dataset (3,4,....n-data) prior to estimating EOF #274

Open Mohsen-cph opened 1 year ago

Mohsen-cph commented 1 year ago

Hi,

I'm using esd package to perform CommonEOFs for multiple soil moisture SM datasets from different sources. The goal is to compare different SM grid datasets in terms of variability in space and time.

For combining two dataset, it is working (i.e., it takes the anomalies and regrid the second data to the first one). However, I would like to combine >2 datasets; but the following ''combine function'' only takes the first two datasets into account, and ignores the rest of the input data, for example:

SM_combined <- combine(SM_ERA5L,SM_CFSNCEP, SM_ESACCI, SM_EnsembleMean) ceof <- EOF(SM_combined) plot(ceof)

Any suggestions please?

brasmus commented 1 year ago

Hi. I see that your netCDF-file is written in a way that may cause problems:

netcdf SWE_ERA5L_168TimeSteps_2000_2020_MackenzieBasin_ShapefileClipped {
dimensions:
    time = UNLIMITED ; // (168 currently)
    longitude = 371 ;
    latitude = 211 ;
variables:
    double time(time) ;
        time:standard_name = "time" ;
        time:units = "day as %Y%m%d.%f" ;
        time:calendar = "proleptic_gregorian" ;
        time:axis = "T" ;
    double longitude(longitude) ;
        longitude:standard_name = "longitude" ;
        longitude:long_name = "longitude" ;
        longitude:units = "degrees_east" ;
        longitude:axis = "X" ;
    double latitude(latitude) ;
        latitude:standard_name = "latitude" ;
        latitude:long_name = "latitude" ;
        latitude:units = "degrees_north" ;
        latitude:axis = "Y" ;
brasmus commented 1 year ago

It's better to use time units such as hours/days/months/years since a date:

netcdf ERA5_tp_mon_2022 {
dimensions:
    longitude = 1440 ;
    latitude = 721 ;
    time = 12 ;
variables:
    float longitude(longitude) ;
        longitude:units = "degrees_east" ;
        longitude:long_name = "longitude" ;
    float latitude(latitude) ;
        latitude:units = "degrees_north" ;
        latitude:long_name = "latitude" ;
    int time(time) ;
        time:units = "hours since 1900-01-01 00:00:00.0" ;
        time:long_name = "time" ;
        time:calendar = "gregorian" ;
    short tp(time, latitude, longitude) ;
        tp:scale_factor = 1.68157988508652e-06 ;
        tp:add_offset = 0.055098646514745 ;
        tp:_FillValue = -32767s ;
        tp:missing_value = -32767s ;
        tp:units = "m" ;
        tp:long_name = "Total precipitation" ;