[R-sig-Geo] TRMM data Analysis
Roy Mendelssohn - NOAA Federal
roy@mende|@@ohn @end|ng |rom no@@@gov
Fri Sep 2 19:05:26 CEST 2022
I think you might get more responses if you also post the error message(s), and/or what came out incorrectly.
HTH,
-Roy
> On Sep 2, 2022, at 2:34 AM, sownal chand <sownalchandfms using gmail.com> wrote:
>
> https://drive.google.com/file/d/1krtBKQUIhupvYKEG1gBV8bgQaQxx96pb/view?usp=drivesdk
>
>
> Attached is the link for the data
>
>
> ---------- Forwarded message ---------
> From: sownal chand <sownalchandfms using gmail.com>
> Date: Fri, Sep 2, 2022, 10:10
> Subject: TRMM data Analysis
> To: <r-sig-geo using r-project.org>
>
>
> Dear sir/madam
>
> I have a data set in NCDF file and was visualizing the data precipitation
> data set but ran into some small errors.
> The code is below:
> *******************************************************
> library(ncdf4)
>
> ncin <- nc_open("c:/Users/Downloads/PreNCDF.nc")
>
> #get longitutes and latitudes
>
> lon <<- ncvar_get(ncin,"lon")
>
> nlon <- dim(lon)
>
> lat <<- ncvar_get(ncin,"lat", verbose=F)
>
> nlat <- dim(lat)
>
> print(ncin)
> #get the time variable and attributes
>
> tori <<- ncvar_get(ncin,"TRMM_3B42RT_7_precipitation") #for time original
>
> tunits <<- ncatt_get(ncin,"TRMM_3B42RT_7_precipitation","units")
>
> nt <- dim(tori)
>
>
> View(nt)
> #get the variable and its attributes
>
> TRMM.array <<- ncvar_get(ncin,"TRMM_3B42RT_7_precipitation") #dimensions
> (lon,lat,time)
> print(TRMM.array)
>
> dim(TRMM.array)
>
> #m is the time slice you want to plot
>
> tmp.slice <- TRMM.array[, , 1]
>
> image(lon, lat, tmp.slice, col = rev(brewer.pal(10, "RdBu")))
>
> #betterway to plot
>
> TRMM.Precip <- tmp.array [, , m] #note this is the same as above
>
> mapCDFtemp <- function(lat,lon,precip) #model and perc should be a string
>
> {
>
> titletext <- "title"
>
> expand.grid(lon, lat) %>%
>
> rename(lon = Var1, lat = Var2) %>%
>
> mutate(lon = ifelse(lon > 180, -(360 - lon), lon),
>
> precip = as.vector(precip)) %>%
>
> #mutate(tas = convert_precip(, "k", "c")) %>%
>
>
>
> ggplot() +
>
> geom_point(aes(x = lon, y = lat, color = precip),
>
> size = 0.8) +
>
> borders("world", colour="black", fill=NA) +
>
> scale_color_viridis(na.value="white",name = "precip") +
>
> theme(legend.direction="vertical", legend.position="right",
> legend.key.width=unit(0.4,"cm"), legend.key.heigh=unit(2,"cm")) +
>
> coord_quickmap() +
>
> ggtitle(titletext)
>
> }
>
>
> *******************************************
> Would really appreciate if it could be corrected and really appreciate your
> assistance
>
> thanking you in advance
> sownalc
>
> [[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
**********************
"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 using 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.
More information about the R-sig-Geo
mailing list