Combine multiple NetCDF files into timeseries multidimensional array python

后端 未结 3 1323
轮回少年
轮回少年 2021-02-10 13:37

I am using data from multiple netcdf files (in a folder on my computer). Each file holds data for the entire USA, for a time period of 5 years. Locations are referenced based on

3条回答
  •  深忆病人
    2021-02-10 14:22

    In parallel to the answer of N1B4, you can also concatenate 4 files along their time dimension using CDO from the command line

    cdo mergetime precip1.nc precip2.nc precip3.nc precip4.nc merged_file.nc 
    

    or with wildcards

    cdo mergetime precip?.nc merged_file.nc 
    

    and then proceed to read it in as per that answer.

    You can add another step from the command line to extract the location of choice by using

    cdo remapnn,lon=X/lat=Y merged_file.nc my_location.nc
    

    this picks out the gridcell nearest to your specified lon/lat (X,Y) coordinate, or you can use bilinear interpolation if you prefer:

    cdo remapbil,lon=X/lat=Y merged_file.nc my_location.nc 
    

提交回复
热议问题