This file contains 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
import numpy as np | |
def get_valid_indices(series: np.ndarray) -> (np.ndarray, np.ndarray): | |
""" | |
Get valid indices from a series. | |
This function gets valid indices from a given series. The valid indices are those where the series | |
value and successor value are not NaN. The function returns two arrays: | |
the valid indices and the valid indices shifted by one to calculate the transition matrix. |
This file contains 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
import numpy as np | |
import scipy | |
def calculate_stationary_state(transition_matrix: np.ndarray) -> np.ndarray: | |
""" | |
Calculate the stationary state of a transition matrix. | |
This function calculates the stationary state of a given transition matrix. The stationary state is the | |
state that the system will converge to over time. It is calculated by finding the eigenvector of the |
This file contains 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
# Download meteorological data archive from https://danepubliczne.imgw.pl/datastore | |
# Code Name | |
# B00300S Air temperature (official) | |
# B00305A Ground temperature (sensor) | |
# B00202A Wind direction (sensor) | |
# B00702A Average wind speed 10 minutes (sensor) | |
# B00703A Maximum wind speed (sensor) | |
# B00608S Precipitation sum 10 minutes | |
# B00604S Daily precipitation sum | |
# B00606S Hourly precipitation sum |
This file contains 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 script reformats multiple CSV files containing environmental data | |
# (see https://gist.github.com/Gdahuks/ae97bebaaff937189a235f9dfecb41e1) | |
# into a single Parquet table with the date and time as index and the station IDs as columns. | |
# Input: B00300S_2012_01.csv, B00300S_2012_01.csv, ..., B00300S_2022_12.csv | |
# 249190890;B00300S;2012-01-01 00:00;-2,9; | |
# 249190890;B00300S;2012-01-01 00:10;-2,8; | |
# 249190890;B00300S;2012-01-01 00:20;-2,9; | |
# 249190890;B00300S;2012-01-01 00:30;-3,3; | |
# ... |