Hi,
Please help me. I am trying to get information on "soi" from the NetCDF
file (please see the attached).
The file is showing this info-
float soi(time=2001, *MCrun=20, members=100*);
:description = "soi";
:long_name = "Southern Oscillation Index";
:units = "";
:level = "sfc";
And Dimentions----
5 dimensions:
*time Size:2001*
description: time
long_name: Time
standard_name: time
units: *days since 0000-01-01 00:00:00*
calendar: noleap
actual_range: 0
*actual_range: 730000*
* MCrun Size:20*
I am not aware of *MCrun* and *members *gaven in a file. I wants to
create csv output and ggplot (line) in form of years.
like this format---
*Longitude Latitude Year soi*
Please help me, my script is here-
rm(list=ls(all=TRUE))
library(ncdf4)
library(ggplot2)
library(ncdf4.helpers)
setwd("D:/work/")
ncfile <-nc_open("posterior_climate_indices_MCruns_ensemble_full_LMRv2.1.nc
")
head(ncfile)
lon <- ncvar_get(ncfile, "lon_npac")
lat<- ncvar_get(ncfile, "lat_npac", verbose = F)
tt<- ncvar_get(ncfile, "time")
units<- ncatt_get(ncfile, "time", "units")
soi <- ncvar_get(ncfile, "soi")
soi_final = data.frame(cbind(lon, lat, tt, soi))
#output
write.csv(amo_final, "soi.csv", row.names = FALSE)
#plot
ggplot(data = soi_final, aes(x = time, y = soi)) +
geom_line() +
xlab("Year") + ylab("soi") +
ggtitle("SOI from 1-2001") +
theme_classic()
thank you
wish you good health.
Regards
S. Singh
posterior_climate_indices_MCruns_ensemble_full_...
<https://drive.google.com/file/d/1r5PzXxShmeOcoBDXUk7Nfr3EzCqmQwGb/view?usp=drive_web>
Extract data from .nc file
2 messages · Shailendra Pratap, Roy Mendelssohn - NOAA Federal
Hi Shailendra: You didn't provide the error messages you received, which makes it difficult to answer. I will say here is at least one typo, in:
write.csv(amo_final, "soi.csv", row.names = FALSE)
You have only defined "soi_final". But I would also be surprised if either of the "cbind()" or "dataframe()" commands works, as everything is of different sizes. HTH, -Roy
On Feb 24, 2021, at 6:19 AM, Shailendra Pratap <baba.pratap73013 at gmail.com> wrote:
Hi,
Please help me. I am trying to get information on "soi" from the NetCDF
file (please see the attached).
The file is showing this info-
float soi(time=2001, *MCrun=20, members=100*);
:description = "soi";
:long_name = "Southern Oscillation Index";
:units = "";
:level = "sfc";
And Dimentions----
5 dimensions:
*time Size:2001*
description: time
long_name: Time
standard_name: time
units: *days since 0000-01-01 00:00:00*
calendar: noleap
actual_range: 0
*actual_range: 730000*
* MCrun Size:20*
I am not aware of *MCrun* and *members *gaven in a file. I wants to
create csv output and ggplot (line) in form of years.
like this format---
*Longitude Latitude Year soi*
Please help me, my script is here-
rm(list=ls(all=TRUE))
library(ncdf4)
library(ggplot2)
library(ncdf4.helpers)
setwd("D:/work/")
ncfile <-nc_open("posterior_climate_indices_MCruns_ensemble_full_LMRv2.1.nc
")
head(ncfile)
lon <- ncvar_get(ncfile, "lon_npac")
lat<- ncvar_get(ncfile, "lat_npac", verbose = F)
tt<- ncvar_get(ncfile, "time")
units<- ncatt_get(ncfile, "time", "units")
soi <- ncvar_get(ncfile, "soi")
soi_final = data.frame(cbind(lon, lat, tt, soi))
#output
write.csv(amo_final, "soi.csv", row.names = FALSE)
#plot
ggplot(data = soi_final, aes(x = time, y = soi)) +
geom_line() +
xlab("Year") + ylab("soi") +
ggtitle("SOI from 1-2001") +
theme_classic()
thank you
wish you good health.
Regards
S. Singh
posterior_climate_indices_MCruns_ensemble_full_...
<https://drive.google.com/file/d/1r5PzXxShmeOcoBDXUk7Nfr3EzCqmQwGb/view?usp=drive_web>
[[alternative HTML version deleted]]
______________________________________________ R-help at r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.
********************** "The contents of this message do not reflect any position of the U.S. Government or NOAA." ********************** Roy Mendelssohn Supervisory Operations Research Analyst NOAA/NMFS Environmental Research Division Southwest Fisheries Science Center ***Note new street address*** 110 McAllister Way Santa Cruz, CA 95060 Phone: (831)-420-3666 Fax: (831) 420-3980 e-mail: Roy.Mendelssohn at noaa.gov www: https://www.pfeg.noaa.gov/ "Old age and treachery will overcome youth and skill." "From those who have been given much, much will be expected" "the arc of the moral universe is long, but it bends toward justice" -MLK Jr.