Skip to content

Instantly share code, notes, and snippets.

View spestana's full-sized avatar
❄️

Steven Pestana spestana

❄️
View GitHub Profile

Pip is a package manager of python. You can download Python libraries from some Python repositories like PyPI. You can also download libraries from a git repository. This is gonna be the issue to be explained in this article.

I don't like to memorize things all the time. So, I guess, I couldn't be working without internet :). Whenever I need to install some python libraries from a git repositories, I see a lot of way to do it. It is really confusing. This should be the reason why I can't memorize it. I can see how a very simple requirement is handled with to many confusing way. There shouldn't be to many way. Some of them is not working neither. At last, I decided to blog it.

As you may know, you can use two protocols which are http and ssh to do something on git repositories. Using protocol ssh instead of http may provide some ease of use. Because of nature of ssh, you can do something with your primary/public keys. So, you don't have to input your credentials all the time. But I'll be

@spestana
spestana / cumulative_gain_loss.py
Created February 15, 2024 16:36
Computes the cumulative gains and losses for a timeseries dataset
import numpy as np
def cumulative_gain_loss(x: np.ndarray, y: np.ndarray):
"""
Computes the cumulative gains and losses for a timeseries dataset
Parameters
------------
x: numpy.ndarray
@spestana
spestana / kaprekar.ipynb
Last active November 1, 2023 16:40
exploring the kaprekar number - I did this as a challange to compute k-like numbers with only built-in python functions and without int-->str conversions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@spestana
spestana / setup-windows-workstation.md
Last active August 15, 2022 17:29
Steps for setting up a geospatial computing workstation on a windows pc
clc; clear;
a0 = 0;
b0 = 0;
solution = lsqnonlin(@(x) difffun_a_b(x), [a0, b0]);
disp(solution);
function difference = difffun_a(a,b)
@spestana
spestana / normalized_stacked_bars.ipynb
Last active August 1, 2022 15:00
Stacked bar chart for two data sets, normalized by the number of points within each bin, with numpy and matplotlib
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@spestana
spestana / archive.py
Last active July 30, 2022 22:17
Script for archiving the previous 30 days of Ribbit Network observations from InfluxDB as textfiles. This is just a temporary solution.
import db
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.dates as mdates
# duration for archive (30d is max on current influx db plan)
duration = '30d'
# sampling frequency (1 min is the maximum rate)
def diurnal_anisotropic_heat(aspect, slope, a_max):
'''
Make a Diurnal Anisotropic Heating (DAH) index (Böhner & Antonic, 2009)
a_max = 202.5 (SSW) from Cristea et al., 2017 in Tuolumne area
'''
DAH = np.cos(np.radians(a_max - aspect)) * np.arctan(np.radians(slope))
return DAH
@spestana
spestana / xarray-da-pcolormesh-example.py
Created December 2, 2021 16:06
xarray pcolormesh and contour plotting of gridded 3d data
import xarray as xr
import numpy as np
import matplotlib.pyplot as plt
# make fake data grid of x and y values
x, y, = np.meshgrid(np.arange(-5,5,0.01),np.arange(-5,5,0.01))
# compute some function on x and y to get z values
z = np.sin(x**2 + y**2) / (x**2 + y**2)
# create xr data array
@spestana
spestana / aircraft-nc2tif.py
Created October 27, 2021 17:30
Converting UW APL Airborne IR and EO (visible) mosiaic imagery from NetCDF files to GeoTIFFs with rioxarray.
import xarray as xr
import rioxarray
# Open airborne TIR or EO mosaic NetCDF file
ds = xr.open_dataset('SNOWEX2020_EO_PLANE_2020Feb08_mosaicked_2020-02-08T194230.nc')
# Write the coordinate reference system with rioxarray
ds.rio.write_crs('epsg:32612', inplace=True)
# Output to geotiff raster