Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Int64 also valid type #154

Merged
merged 2 commits into from
Apr 21, 2022
Merged

Int64 also valid type #154

merged 2 commits into from
Apr 21, 2022

Conversation

milankl
Copy link
Contributor

@milankl milankl commented Apr 14, 2022

Using Int64 for the time coordinate seems to work without problems

output_startdate = DateTime(2000,1,1)
time_string = "hours since $(Dates.format(output_startdate, "yyyy-mm-dd HH:MM:0.0"))"
dim_time = NcDim("time",0,unlimited=true)
var_time = NcVar("time",dim_time,t=Int64,atts=Dict("units"=>time_string,"long_name"=>"time"))

and then on every time step with changing time_hrs

NetCDF.putvar(netcdf_file,"time",[round(Int64,time_hrs)],start=[i_out])
NetCDF.sync(netcdf_file)

ncdump then yields

milan@milanmac SpeedyWeather.jl % ncdump -c run0006/run0006.nc
netcdf run0006 {
dimensions:
	lat = 48 ;
	time = UNLIMITED ; // (41 currently)
	lon = 96 ;
	lev = 8 ;
variables:
	int64 time(time) ;
		time:units = "hours since 2000-01-01 00:00:0.0" ;
		time:long_name = "time" ;
...
 time = 0, 6, 12, 18, 24, 30, 36, 42, 48, 54, 60, 66, 72, 78, 84, 90, 96, 
    102, 108, 114, 120, 126, 132, 138, 144, 150, 156, 162, 168, 174, 180, 
    186, 192, 198, 204, 210, 216, 222, 228, 234, 240 ;

milankl and others added 2 commits April 14, 2022 14:05
Copy link
Member

@visr visr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's right, it's good to add Int64 as well since it's a commonly used type. The list is not exhaustive, see nctype2jltype:

    NC_BYTE => Int8,
    NC_UBYTE => UInt8,
    NC_SHORT => Int16,
    NC_USHORT => UInt16,
    NC_INT => Int32,
    NC_UINT => UInt32,
    NC_INT64 => Int64,
    NC_UINT64 => UInt64,
    NC_FLOAT => Float32,
    NC_DOUBLE => Float64,
    NC_CHAR => ASCIIChar,
    NC_STRING => String,

@visr visr merged commit f274e78 into JuliaGeo:master Apr 21, 2022
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants