This is my first time using netCDF and I'm trying to wrap my head around working with it.
I have several netcdf version 3 files (NOAA NARR air.2m daily average values ββall year long). Each file covers a year between 1979 and 2012. This is a 349 x 277 grid with a resolution of 32 km. Data has been downloaded from here .
Measurement is time (hours from 1/1/1800), and my variable of interest is air. I need to calculate the accumulated days with a temperature of 0. For example
Day 1 = +4 degrees, accumulated days = 0 Day 2 = -1 degrees, accumulated days = 1 Day 3 = -2 degrees, accumulated days = 2 Day 4 = -4 degrees, accumulated days = 3 Day 5 = +2 degrees, accumulated days = 0 Day 6 = -3 degrees, accumulated days = 1
I need to save this data in a new netcdf file. I am familiar with Python and somewhat with R. What is the best way to cycle every day, check the value of previous days and based on this, output the value to a new netcdf file with exactly the same dimension and variable ... or just add another variable to the original netcdf file with the result I'm looking for.
Is it better to leave all files separate or merge them? I combined them with ncrcat and it worked fine, but the file is 2.3gb.
Thanks for the input.
My current progress in python:
import numpy import netCDF4 #Change my working DIR f = netCDF4.Dataset('air7912.nc', 'r') for a in f.variables: print(a) #output = lat long x y Lambert_Conformal time time_bnds air f.variables['air'][1, 1, 1] #Output 298.37473
To help me better understand what data structure I'm working with? Is ['air'] key in the above example and [1,1,1] are also keys? to get the value 298.37473. How can I then skip [1,1,1]?