[R-sig-Geo] Converting a variable's units from gigatons to teratons
Sarah Goslee
@@r@h@go@|ee @end|ng |rom gm@||@com
Thu Mar 28 17:03:56 CET 2019
ncvar_get() should return a data frame, so just
get2.teratons <- get2 / 1000
Even if it's a higher-dimensional array, that will work.
You could then write it back with ncvar_put(), subject to the data
type of that variable in the NetCDF file.
Sarah
On Thu, Mar 28, 2019 at 11:55 AM rain1290--- via R-sig-Geo
<r-sig-geo using r-project.org> wrote:
>
> Hi there,
> I am currently working with a variable whose units are expressed in gigatons. However, I would like to convert all of these values in this variable to teratons. Effectively, I would have to somehow have R divide all values (90 values) within the variable by 1000.
> So far, I have read in the variable (called CanESM2) as follows:
> ncfname1 <- "cumulative_emissions_RCP45.nc"
> Model3 <- nc_open(ncfname1)
> get2 <- ncvar_get(Model3, "CanESM2")
> Is there a way to accomplish this conversion?
> Thanks, and any assistance would be greatly appreciated!
>
> [[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo using r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
--
Sarah Goslee (she/her)
http://www.numberwright.com
More information about the R-sig-Geo
mailing list