I have a lot of netCDF files where they created from tif files using python gdal library. I want to merge each of these files in an large nc file, but they don't have a time variable.
I tried the method described here but when I'm going to see the timestamps of each band of the resulted large nc file, it is zeros for all the files.
Moreover, the result of ncdump -h name-of-the-file
is as following.
netcdf g2_BIOPAR_VCI_201701010000_AFRI_PROBAV_V1.0.h5_trans {
dimensions:
lon = 10081 ;
lat = 8961 ;
variables:
char crs ;
crs:grid_mapping_name = "latitude_longitude" ;
crs:long_name = "CRS definition" ;
crs:longitude_of_prime_meridian = 0. ;
crs:semi_major_axis = 6378137. ;
crs:inverse_flattening = 298.257223563 ;
crs:spatial_ref = "GEOGCS[\"WGS 84\",DATUM[\"WGS_1984\",SPHEROID[\"WGS 84\",6378137,298.257223563,AUTHORITY[\"EPSG\",\"7030\"]],AUTHORITY[\"EPSG\",\"6326\"]],PRIMEM[\"Greenwich\",0],UNIT[\"degree\",0.0174532925199433],AUTHORITY[\"EPSG\",\"4326\"]]" ;
crs:GeoTransform = "-30 0.008927685745461759 0 40 0 -0.008927575047427742 " ;
double lat(lat) ;
lat:standard_name = "latitude" ;
lat:long_name = "latitude" ;
lat:units = "degrees_north" ;
double lon(lon) ;
lon:standard_name = "longitude" ;
lon:long_name = "longitude" ;
lon:units = "degrees_east" ;
byte Band1(lat, lon) ;
Band1:long_name = "GDAL Band Number 1" ;
Band1:_Unsigned = "true" ;
Band1:valid_range = 0s, 255s ;
Band1:_FillValue = 0b ;
Band1:VCI_CLASS = "DATA" ;
Band1:VCI_MISSING_VALUE = 251 ;
Band1:VCI_NB_BYTES = "Uint8" ;
Band1:VCI_OFFSET = -5 ;
Band1:VCI_ORDER_BYTES = 1 ;
Band1:VCI_PRODUCT = "VCI" ;
Band1:VCI_SCALING_FACTOR = 0.5f ;
Band1:grid_mapping = "crs" ;
// global attributes:
:GDAL_ARCHIVE_FACILITY = "VITO" ;
:GDAL_CENTRE = "VITO" ;
:GDAL_ELLIPSOID_NAME = "WGS84" ;
:GDAL_GEODATE_NAME = "WGS84" ;
:GDAL_INSTRUMENT_ID = "VGT3" ;
:GDAL_LAT = 40 ;
:GDAL_LONG = -30 ;
:GDAL_OTHER = "GLS" ;
:GDAL_OVERALL_QUALITY_FLAG = "OK" ;
:GDAL_PIXEL_SIZE = "1km" ;
:GDAL_PRODUCT = "Mars VCI data" ;
:GDAL_PRODUCT_ALGORITHM_VERSION = 1. ;
:GDAL_PRODUCT_TIME = "2017-01-12" ;
:GDAL_PROJECTION_NAME = "PlateCarree" ;
:GDAL_REGION_NAME = "AFRI" ;
:GDAL_SATELLITE = "PROBAV" ;
:GDAL_TEMPORAL_NOMINAL = "2017-01-01" ;
:GDAL_TEMPORAL_START = "2017-01-01" ;
:GDAL_TEMPORAL_STOP = "2017-01-10" ;
:Conventions = "CF-1.5" ;
:GDAL = "GDAL 2.3.3, released 2018/12/14" ;
:history = "Mon Feb 24 14:29:37 2020: GDAL CreateCopy( ../2017/20170101/g2_BIOPAR_VCI_201701010000_AFRI_PROBAV_V1.0.h5_trans.nc, ... )" ;
What I want to do is to create a time variable, which will be the same as the global variable: GDAL_TEMPORAL_STOP and merge each file in one large nc file. Ideally I prefer to do this in python. I assume there might be some way to copy the global variable:GDAL_TEMPORAL_STOP = "2017-01-10" ;
and copy it as time variable for every file, but I couldn't find a way to do it, so this is where I need your help.