Giter Site home page Giter Site logo

Comments (2)

quantifish avatar quantifish commented on August 13, 2024

I've added mfe_average_sst but the projection looks wrong. Needs some work.

Jim got me some different SST data for the PHC project. See the files ERA5_data_script.R etc for how to get and plot these data. I used this code:

library(ecmwfr)

library(raster)
library("ncdf4")

library("ncdf.tools")

library(ggplot2)

library(ggthemes)

library(sf)
library(nzsf)

ncfile <- "era5-nz_sst_to_2020.nc"
rr <- brick(x = ncfile)
rr <- stack(x = ncfile)
nlayers(rr)
rr
raster::plot(rr)

df <- rasterToPoints(rr) %>%
data.frame() %>%
pivot_longer(cols = c(-x, -y)) %>%
separate(col = name, into = c("year", "month", "day", "hr", "min", "sec"), sep = "\.") %>%
mutate(year = gsub("X", "", year), value = value - 273.15)

p <- ggplot(data = df %>% filter(year == "2000")) +
geom_raster(aes(x = .data$x, y = .data$y, fill = .data$value)) +
facet_wrap(year ~ month)
p

r1 <- rr[[1]]
sf_stat <- get_statistical_areas("CRA") %>%
filter(area %in% c(901:907)) %>%
st_transform(crs = crs(rr), check = TRUE) %>%
dplyr::select(MFISH_ID, area)
average_temperature <- raster::extract(x = rr, y = sf_stat, df = TRUE) %>%
full_join(data.frame(sf_stat), by = c("ID" = "MFISH_ID")) %>%
dplyr::select(-geometry, -ID) %>%
pivot_longer(-area) %>%
separate(col = name, into = c("year", "month", "day", "hr", "min", "sec"), sep = "\.") %>%
mutate(year = gsub("X", "", year), value = value - 273.15) %>%
group_by(year, month, area) %>%
summarise(temp = mean(value, na.rm = TRUE))
save(average_temperature, file = "average_temperature.rda")

from nzsf.

quantifish avatar quantifish commented on August 13, 2024

Not sure what is wrong with the MFE raster. Think I will drop it as the projection looks buggered.

from nzsf.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.