Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
combining netcdf data
#1
Hi all,

I would like to combine netcdf files from the copernicus platform (climate data, i.e. NDVI and soil moisture). The files are provided in form of a grid of coordinates and respective measurements per set of coordinates in a single file for each time of measurement.

I do not have any experience in coding, therefore I researched the solution below. That however leads to an extremely large filesize. I therefore would like to cut the data in one timeseries for a specific set of coordinates in the same step. I work on a win10 machine with the latest anaconda / python environment.

Any input is greatly appreciated!



1.
import netCDF4
import numpy
import xarray

2.
ds = xarray.open_mfdataset(‚filename.*.nc',combine = 'by_coords', concat_dim="time")

3.
ds.to_netcdf('filename_combined.nc')



Thank you!


here is description I pulled from one of the files:

<xarray.Dataset>
Dimensions: (lat: 720, lon: 1440, time: 1)
Coordinates:
* lat (lat) float32 89.875 89.625 89.375 ... -89.375 -89.625 -89.875
* lon (lon) float32 -179.875 -179.625 -179.375 ... 179.625 179.875
* time (time) datetime64[ns] 2000-01-01
Data variables:
nobs (time, lat, lon) float32 dask.array<shape=(1, 720, 1440), chunksize=(1, 720, 1440)>
sensor (time, lat, lon) float32 dask.array<shape=(1, 720, 1440), chunksize=(1, 720, 1440)>
freqbandID (time, lat, lon) float32 dask.array<shape=(1, 720, 1440), chunksize=(1, 720, 1440)>
sm (time, lat, lon) float32 dask.array<shape=(1, 720, 1440), chunksize=(1, 720, 1440)>
Attributes:
title: C3S Surface Soil Moisture merged PASSIVE Product
institution: EODC (AUT); TU Wien (AUT); VanderSat B.V. (NL)
contact: [email protected]
source: LPRMv05/SMMR/Nimbus 7 L3 Surface Soil Moistur...
platform: Nimbus 7, DMSP, TRMM, AQUA, Coriolis, GCOM-W1...
sensor: SMMR, SSM/I, TMI, AMSR-E, WindSat, AMSR2, MIRAS
references: http://www.esa-soilmoisture-cci.org; Liu, Y.Y...
product_version: v201912.0.0
Conventions: CF-1.6
standard_name_vocabulary: NetCDF Climate and Forecast (CF) Metadata Con...
summary: The data set was produced with funding from t...
keywords: Soil Moisture/Water Content
naming_authority: EODC
keywords_vocabulary: NASA Global Change Master Directory (GCMD) Sc...
cdm_data_type: Grid
comment: These data were produced as part of the Coper...
creator_name: Earth Observation Data Center (EODC)
creator_url: https://www.eodc.eu
creator_email: [email protected]
project: Copernicus Climate Change Service.
license: Copernicus Data License
time_coverage_resolution: P1D
geospatial_lat_min: -90.0
geospatial_lat_max: 90.0
geospatial_lon_min: -180.0
geospatial_lon_max: 180.0
geospatial_vertical_min: 0.0
geospatial_vertical_max: 0.0
geospatial_lat_units: degrees_north
geospatial_lon_units: degrees_east
geospatial_lat_resolution: 0.25 degree
geospatial_lon_resolution: 0.25 degree
spatial_resolution: 25km
time_coverage_start: 1999-12-31T12:00:00Z
time_coverage_end: 2000-01-31T12:00:00Z
time_coverage_duration: P1M
id: C3S-SOILMOISTURE-L3S-SSMV-PASSIVE-MONTHLY-200...
tracking_id: 504295ec-67ef-4c6e-a2ba-5f5ed376cad2
date_created: 2020-05-15T07:18:11Z
history: 2020-05-15T07:18:11.833569 mean calculated
Reply
#2
My suggestion would be to post under jobs and offer compensation.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  python Extract sql data by combining below code. mg24 1 968 Oct-03-2022, 10:25 AM
Last Post: mg24
  Selecting netcdf data files Jodman92 4 3,046 Nov-21-2018, 10:56 PM
Last Post: Larz60+
  Converting units in NetCdf Files in Python fyec 1 4,137 Jun-18-2018, 12:53 PM
Last Post: gontajones
  Storing Python data output as a Netcdf file Lightning1800 1 2,642 May-16-2018, 10:14 PM
Last Post: micseydel
  netCDF issue with filling a variable HeavyLoads 1 11,509 Oct-03-2016, 08:34 PM
Last Post: micseydel

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020