Skip to content

Instantly share code, notes, and snippets.

View M3nin0's full-sized avatar
:electron:
Focusing

Felipe M3nin0

:electron:
Focusing
View GitHub Profile
# Autor: Felipe Menino Carlos
# Data: 11/09/2020
'
Calcula o SpeedUp
'
speedUp <- function(serialTime, parallelTime)
{
return(serialTime / parallelTime)
}
@M3nin0
M3nin0 / drill_datacube.py
Created October 3, 2020 01:41
Drill an BDC-Datacube
# STAC.py
bdc_stac_service = stac.STAC('http://brazildatacube.dpi.inpe.br/stac/')
# Select a collection and get items
collection = bdc_stac_service.collection('S2_10_16D_STK-1')
items = collection.get_items(filter={'bbox':'-61, 2.8, -60, 1.8', 'datetime':'2018-08-01/2019-07-31'})
# Generate a "1D" (One variable) datacube
## mutate_1d_cube from github.com/M3nin0/xarray-stac/
cube1d = mutate_1d_cube(items['features'], 'NDVI')
@M3nin0
M3nin0 / sits-bahia-classification.yaml
Created October 30, 2020 04:55
An reana.yaml configuration to execute a classification using e-sensing/sits package
version: 0.6.0
inputs:
directories:
- R
options:
CACHE: on # Cache the steps results
workflow:
type: serial
specification:
steps:
@M3nin0
M3nin0 / install-rsits.R
Last active December 3, 2020 01:17
R Script to install e-sensing/sits package
chooseCRANmirror(graphics=FALSE, ind=1)
# Install devtools, rmarkdown, knitr, testthat and Rcpp if not already available
install.packages(c("devtools", "rmarkdown", "Rcpp", "knitr", "testthat", "remotes"))
# Please install the Suggested packages that are used by sits
install.packages(c("DBI","dendextend", "dtwclust","dtwSat", "e1071", "flexclust",
"imager", "imputeTS", "kohonen", "lwgeom", "MASS", "methods",
"mgcv", "nnet", "proto", "proxy", "ptw", "ranger", "RCurl",
"RSQLite", "signal", "xgboost", "zoo", "randomForest", "desc"))
@M3nin0
M3nin0 / sits-config.yaml
Created December 4, 2020 11:16
Configuration file to execute SITS R Package with multiple vegetation index bands
default:
# estimated relative growth size of R memory relative to block size
R_memory_bloat : 4
R_processing_bloat : 5
# minimum number of samples for multicore processing
minimum_number_samples : 1000
# Data cube types known to sits
@M3nin0
M3nin0 / deforestation_sentinel2_sampling.R
Created January 11, 2021 13:26
Script to randomly select 80 sample points from the data set provided in https://doi.pangaea.de/10.1594/PANGAEA.921387
# Adapted from: https://github.com/albhasan/deforestation-sentinel2/blob/master/06_validation/validate_results.R
# validation_dataset_bands.csv is avaliable online on: https://doi.pangaea.de/10.1594/PANGAEA.921387?format=html#download
set.seed(666)
validation_dataset_bands <- readr::read_csv("validation_dataset_bands.csv")
deforestation <- dplyr::filter(validation_dataset_bands, label == "Deforestation")
non_forest <- dplyr::filter(validation_dataset_bands, label == "Non-Forest")
forest <- dplyr::filter(validation_dataset_bands, label == "Forest")
import numpy
from wtss import WTSS
service = WTSS('https://brazildatacube.dpi.inpe.br/', access_token='seu-token')
cbers4_coverage = service['CB4_64_16D_STK-1']
#
# bandas
#
@M3nin0
M3nin0 / lulc-classification-reprozip-trace.yaml
Last active April 19, 2021 20:24
System Trace for a LULC Classification using SITS R Package. Generated by ReproZip
# Author: Felipe Menino Carlos
# Date: 19/04/2021
#
# ReproZip configuration file
# This file was generated by reprozip 1.0.16 at 2021-03-15T02:04:56+00:00
# You might want to edit this file before running the packer
# See 'reprozip pack -h' for help
# Run info
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@M3nin0
M3nin0 / 01_ExtractTimeSeries.R
Created April 25, 2021 12:39
Exemplo de especificação de um workflow de classificação utilizando Common Workflow Language (CWL).
# Autor: Felipe Menino Carlos
# Data: 25/04/2021
set.seed(777)
library(sits)
#
# Auxiliary function
#
extract_ts_by_sample_location <- function(collection, start_date, end_date, bands, sample_file) {