Skip to content

Instantly share code, notes, and snippets.

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

Felipe M3nin0

:electron:
Focusing
View GitHub Profile
@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")
@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 / 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-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 / 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')
# Autor: Felipe Menino Carlos
# Data: 11/09/2020
'
Calcula o SpeedUp
'
speedUp <- function(serialTime, parallelTime)
{
return(serialTime / parallelTime)
}
@M3nin0
M3nin0 / stac-intersects.py
Created August 5, 2020 14:49
STAC.py intersects method
import stac
bdc_stac_service = stac.STAC('http://brazildatacube.dpi.inpe.br/bdc-stac/0.8.0/')
collection = bdc_stac_service.search({'collections': ['LC8SR'], "intersects": {"type": "Point", "coordinates": [-45, -13] }, "limit": 10})
import numpy as np
import pandas as pd
from sklearn import linear_model
import matplotlib.pyplot as plt
# Carregando os dados
data_owd = pd.read_csv('https://covid.ourworldindata.org/data/owid-covid-data.csv')
# Filtrando os dados (Canadá)
can = data_owd[data_owd.iso_code == 'CAN']
@M3nin0
M3nin0 / powernoise.m
Last active May 11, 2020 13:36
powernoise for octave
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Arbitrary Spectral Slope Noise Generation %
% with OCTAVE Implementation %
% %
% From Little, 1992. Adapted from R. Rosa (08/08/14) %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function x = powernoise(beta, N, varargin)
% Generate samples of power law noise. The power spectrum
% of the signal scales as f^(-beta).
#include <iostream>
// Idea from: https://stackoverflow.com/questions/5171739/tostring-override-in-c
class Teste
{
private:
int a;
public:
Teste(int a)