Menu

concatenation of files with different dimensions

Help
lal
2016-02-02
2016-02-04
  • lal

    lal - 2016-02-02

    Hi
    I have two files and the metadata for them is:

    1) File1:
    dimensions:
    time = 20089;
    lat = 5;
    lon = 38;
    variables:
    double time(time=20089);
    :units = "days since 1960-01-01 00:00:00.0 +0545";
    :time_origin = "1960-01-01 00:00:00";

    float rain_der_ens(time=20089, lat=5, lon=38);
      :_FillValue = -9999.0f; // float
      :missing_value = -9999.0f; // float
    
    float longitude(lon=38);
      :units = "degrees east";
    
    float latitude(lat=5);
      :units = "degrees north";
    

    2) File2:
    dimensions:
    time = 20089;
    lat = 3;
    lon = 47;
    variables:
    double time(time=20089);
    :units = "days since 1960-01-01 00:00:00.0 +0545";
    :time_origin = "1960-01-01 00:00:00";

    float rain_der_ens(time=20089, lat=3, lon=47);
      :_FillValue = -9999.0f; // float
      :missing_value = -9999.0f; // float
    
    float longitude(lon=47);
      :units = "degrees east";
    
    float latitude(lat=3);
      :units = "degrees north";
    

    As we see the size of lat lon dimensions is different. Also some of the lat and lon values are repeated between the two files(not the lat-lon combination but individual lat or lon values). How can I concatenate files in this scenario. I have written a python script to concatenate the files but the execution time becomese too long as the size of the files to concatenate increases.

    Please let me know how to handle this type of concatenation efficiently. I had tried nco operators but I think they do not handle this scenario(I hope I am wrong here).

     

    Last edit: lal 2016-02-02
  • Charlie Zender

    Charlie Zender - 2016-02-03

    Interesting question. I can't think of any elegant solutions. Anyone else?
    cz

     
  • John

    John - 2016-02-03

    I visualize the spatial overlap to be something like this:

    xxxxxxxxxx
    xxxxxxxxxx
    xxxxxoooooooooo
    xxxxxoooooooooo
         oooooooooo
         oooooooooo
    

    where x is file 1, and o is file 2. I would divide each file into 2 files, resulting in 4 files that lie like this:

    1111122222
    1111122222
    111113333344444
    111113333344444
         3333344444
         3333344444
    

    a) Concat 2 with 3;
    b) extend the dimensions of 1 and 4; then
    c) concat 1, the result of (a), and 4.

    Not elegant (rather, painful), but should work?

     

    Last edit: John 2016-02-03
  • lal

    lal - 2016-02-04

    Thanks John and Charlie.
    John: I did not quite understand.

    I have found a similar question asked on this forum: http://sourceforge.net/p/nco/discussion/9830/thread/2782cde1/

    The recommendation on that thread was also an custom script to do the merging.

    I have meanwhile made my script faster by writting it in c and using openmp to parallelize. So it is not bothering me anymore.

     

Log in to post a comment.

MongoDB Logo MongoDB