This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # play all samples in the module at note "C-3" | |
| playSample(mod) | |
| # play chromatic scales of octaves 2 and 3 using the 23rd sample | |
| data(period_table) | |
| for (i_note in as.vector(outer(names(period_table)[-1:-2], | |
| c(2:3), function(x, y) paste(x, y, sep = "")))) | |
| { | |
| print(i_note) | |
| playSample(PTSample(mod, 23), 0.1, T, i_note, 0.5) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # select a sample: | |
| plot_samp <- PTSample(mod, 25) | |
| # generate power spectrum | |
| spec <- powspec(waveform(plot_samp), | |
| wintime = 0.1, | |
| steptime = 0.005) | |
| spec_cutoff <- quantile(log10(spec), 0.01) | |
| spec[log10(spec) < spec_cutoff] <- 10^spec_cutoff |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # load the required packages | |
| require(ProTrackR) | |
| # set up a connection to 'cyberrid.mod': | |
| con <- url("http://api.modarchive.org/downloads.php?moduleid=40293", "rb") | |
| # download module: | |
| mod <- read.module(con) | |
| close(con) | |
| rm(con) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # required packages | |
| require(rgdal) | |
| require(leaflet) | |
| require(htmlwidgets) | |
| # select files for which geotags need to | |
| # be extracted and store filenames in data.frame | |
| file_info <- data.frame(file.name = choose.files(filters = Filters["jpeg",])) | |
| # function to get a parameter value from EXIF code, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # for each file obtain the EXIF codes and extract the coordinates | |
| GPStags <- apply(array(file_info$file.name), 1, function(x) { | |
| EXIF_code <- NULL | |
| try (EXIF_code <- attr(GDALinfo(x), "mdata"), silent = T) | |
| if (is.null(EXIF_code)) return(data.frame(lon = NA, lat = NA, dateTime = NA)) else return(get_EXIF_coordinate(EXIF_code)) | |
| }) | |
| #bind the results: | |
| GPStags <- do.call(rbind, GPStags) | |
| # store in the data.frame |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # creat map widget: | |
| map <- leaflet() %>% addTiles() %>% | |
| addCircleMarkers(lng = file_sub$lon, | |
| lat = file_sub$lat, | |
| color = pal(file_sub$hours), | |
| popup = paste0(file_sub$dateTime, "<br/>", | |
| round(file_sub$lon, 6), "<br/>", | |
| round(file_sub$lat, 6))) %>% | |
| addLegend(position = "topleft", pal = pal, values = file_sub$hours, title = "hours past<br/>midnight") | |
| map |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # save map as html: | |
| saveWidget(map, "map.html") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## load required packages: | |
| require(sp) | |
| require(raster) | |
| require(ncdf4) | |
| require(ncdf.tools) | |
| require(rgeos) | |
| require(maptools) | |
| ############################################################### | |
| ## STEP 1: load the water currents and wind data |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require(raster) | |
| require(KernSmooth) | |
| require(maptools) | |
| ## load the simulation results. See the previous blog post | |
| ## how this file was created. This data file contains | |
| ## an object named 'part.results', which is a list | |
| ## of SpatialPointsDataFrame objects. | |
| load("output/out.RData") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## This package is used to retrieve data from openstreetmap.org: | |
| require(osmar) | |
| ## This pacakge is used to process the spatial data: | |
| require(rgeos) | |
| ## This package is used to convert the data from openstreetmap into something workable: | |
| require(maptools) | |
| ## function to retrieve a relation from openstreetmap and convert it | |
| ## into a SpatialPolygons object: | |
| OSM_relation_to_SP <- function(rel) { |