1

I have a set of 3-hourly temperature netcdf files over the last 16 years. Each file is only one time dimension, the 3-hourly temperature for each pixel. I would like to create a new .tif or netcdf file (preferably .tif) of the daily average temperature. This would be equivalent to something like the Mosaic to New Raster tool in ArcGIS but for netcdf files. I prefer to use python - arcpy, netcdf4, numpy, or similar packages. Following is what I have so far, which selects the daily netcdf to be averaged.

def averagerasters():
    raslist = glob.glob(pathlist[0] + "/*.nc")
    startind = 0
    endind = 20 #Too expensive to iterate through entire 50k files
    while startind <len(raslist):
        avglist =[]
        firstras = raslist[startind]
        matchras = firstras[-37:-30]
        for ras in raslist[startind:endind]:
            if matchras in ras:
                avglist.append(ras)
        print "Here is average list", str(avglist) 
        outname = matchras+'.tif'

        ####code to created averaged daily raster####

        startind+=len(avglist)
        endind =startind+20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.