-
Notifications
You must be signed in to change notification settings - Fork 33
Open
Description
Hi,
I want first of all to thank you for this amazing packages.
I am using NCDatasets
to derive time series spatial maps of climate data. I have 64.0 GB of RAM and I am having an issue of OutOfMemoryError()
.
I am wandering if there is a solution such that new NetCDF is written gradually to disk instead of RAM?
Many thanks for any help you may provide,
Joseph
# Create a NetCDFmeteo file
NetCDFmeteo = NCDatasets.NCDataset(Path_NetCDFmeteo_Output,"c")
# Create a 3D array for the time series
Precip_Array = fill(NaN::Float64, Metadatas.N_Width, Metadatas.N_Height, Nit)
Pet_Array = fill(NaN::Float64, Metadatas.N_Width, Metadatas.N_Height, Nit)
Temp_Array = fill(NaN::Float64, Metadatas.N_Width, Metadatas.N_Height, Nit)
# Transform the data to a 3D array
Threads.@threads for iX=1:Metadatas.N_Width
Threads.@threads for iY=1:Metadatas.N_Height
if Subcatchment[iX,iY] == 11
Threads.@threads for iT=1:Nit
Precip_Array[iX,iY,iT] = Precip[iT]
Pet_Array[iX,iY,iT] = Pet[iT]
Temp_Array[iX,iY,iT] = Temp[iT]
end # Threads.@threads for iT=1:Nit
end # if Subcatchment[iX,iY] == 1
end # for iY=1:Metadatas.N_Height
end # for iX=1:Metadatas.N_Width
# Define the dimension "x" and "y" and time
NCDatasets.defDim(NetCDFmeteo,"x", Metadatas.N_Width)
NCDatasets.defDim(NetCDFmeteo,"y", Metadatas.N_Height)
NCDatasets.defDim(NetCDFmeteo,"time", Nit)
# Define a global attribute
NetCDFmeteo.attrib["title"] = "Timoleague climate dataset"
NetCDFmeteo.attrib["units"] = "mm"
# == time input ==========================================
Keys = "time"
Time_NetCDF = NCDatasets.defVar(NetCDFmeteo, Keys, Time_Array[1:Nit], ("time",), deflatelevel=9, shuffle=true, fillvalue=NaN)
# Time_NetCDF[:] = Time_Array[1:Nit]
# Time_NetCDF.attrib["units"] = "Dates.DateTime({Int64})"
Time_NetCDF.attrib["calendar"] = "proleptic_gregorian"
# == Precipitation input ==========================================
Keys = "precip"
Precip_NetCDF = NCDatasets.defVar(NetCDFmeteo, Keys, Float64, ("x", "y", "time"), deflatelevel=9, shuffle=true, fillvalue=NaN)
Precip_NetCDF[:,:,:] = Precip_Array
Precip_NetCDF.attrib["units"] = "mm"
Precip_NetCDF.attrib["comments"] = "precipitation"
close(NetCDFmeteo)
'''
Metadata
Metadata
Assignees
Labels
No labels