Skip to content

Instantly share code, notes, and snippets.

View NikosAlexandris's full-sized avatar
🙂

Nikos Alexandris NikosAlexandris

🙂
View GitHub Profile

Keybase proof

I hereby claim:

  • I am nikosalexandris on github.
  • I am alexandris (https://keybase.io/alexandris) on keybase.
  • I have a public key ASA2XeMgjqmIf05ZEbEocuTnFMJ6gnxJmVzFbtS3VxyBKQo

To claim this, I am signing this object:

Driver: HDF5/Hierarchical Data Format Release 5
Files: ECOSTRESS_L2_LSTE_05525_002_20190627T070809_0600_01.h5
Size is 512, 512
Metadata:
  SDS_Emis1_add_offset=0.49
  SDS_Emis1_coordsys=cartesian
  SDS_Emis1_err_add_offset=0
  SDS_Emis1_err_coordsys=cartesian
  SDS_Emis1_err_format=scaled
@NikosAlexandris
NikosAlexandris / issue_with_numpy.genfromtxt_usecols.md
Created August 5, 2020 07:22
Issue with numpy's `numpy.genfromtxt` and 'usecols' argument
# hardcodings
working_directory = '/home/jovyan/binder/'
csvdata = 'who_covid_19_sit_rep_time_series.csv'
# librairies
import os
@NikosAlexandris
NikosAlexandris / example_compose_s1_grd_data.sh
Created November 20, 2020 00:01
Examples fetching composite S1_GRD data from GEE
❯ python geesarfetcher/example_compose_s1_grd_data_over_epsg4326.py
Region sliced in 4 subregions.
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:05<00:00, 1.38s/it]
Length of pixel_values: 10710
Generating image of shape (height x width) (119, 90)
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 10710/10710 [00:01<00:00, 5594.78it/s]
❯ python geesarfetcher/example_compose_s1_grd_data_over_srorg6974.py
Region sliced in 4 subregions.
100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:04<00:00, 1.24s/it]
We can make this file beautiful and searchable if this error is corrected: It looks like row 7 should actually have 3 columns, instead of 2 in line 6.
title URL verbs
How to add new columns to CSVs with the same text in all lines https://askubuntu.com/questions/1193534/how-to-add-new-columns-to-csvs-with-the-same-text-in-all-lines/1193544#1193544 put, reorder
csv text-processing question https://unix.stackexchange.com/questions/555643/csv-text-processing-question/555667#555667 put, unsparsify, fill-down, count-similar, filter, reorder, cut
how to keep rows if there are a certain number of observations based on the first column? https://unix.stackexchange.com/questions/558147/how-to-keep-rows-if-there-are-a-certain-number-of-observations-based-on-the-firs/558258#558258 count-similar, filter, cut
Add Column to CSV based on Filename https://stackoverflow.com/questions/59422250/batch-script-add-column-to-csv-based-on-filename/59426724#59426724 put
Concatenating columns of the same csv file to create a new column with a new heading https://unix.stackexchange.com/a/558359/195582 put
How can I replace strings in a given column of a table using awk and regex? https
@NikosAlexandris
NikosAlexandris / streaming-and-memory_overview_table.md
Last active September 6, 2021 00:25
Overview of Miller's streaming processing, and memory usage

Overview of Miller's streaming processing, and memory usage

Miller is streaming when possible (exceptions noted below) -- most verbs:

  • operate and store in memory a single and independent record at a time
  • don't have a state to retain from one record to the next
  • don't wait for complete ingestion of input before producing any output
  • (likewise, "statements" (i.e. $z = $x + $y) in the Miller programming language are implicit callbacks executed once per record)
  • operate on files which are larger than the system's memory
  • consume other programms output via pipe, e.g. tail -f some-file | mlr --some-flags
@NikosAlexandris
NikosAlexandris / miller_for_examples.md
Created September 10, 2021 13:10
Examples of for loops with Miller

Examples using for

Simple

  • Print
for (k, v in $*) {
  print "KEY IS ". k . " VALUE IS ". v;
}
### Input configuration
#
# Example configuration:
# You can get the names of your inputs by running: swaymsg -t get_inputs
# Put your touchpad's ID to replace "Touchpad-ID" (keep the quotation marks)
input type:touchpad {
dwt enabled
tap enabled
natural_scroll enabled
@NikosAlexandris
NikosAlexandris / gist:2ea12e74cc72f7eb1a326e8b9b903aef
Created October 27, 2023 12:55
Checking chunk sizes [DRAFT]
@app.command(
'check-chunks',
no_args_is_help=True,
help='Check for chunk size consistency along series of files in a format supported by Xarray',
)
def check_chunk_consistency(
source_directory: Annotated[Path, typer_argument_source_directory],
pattern: Annotated[str, typer_option_filename_pattern] = "*.json",
verbose: Annotated[int, typer.Option(..., "--verbose", "-v", count=True, help="Increase verbosity level.")] = 0,
):
@NikosAlexandris
NikosAlexandris / suggest.py
Created November 3, 2023 19:33
Determine optimal chunk shape for a 3D array
import math
import operator
import numpy as np
from itertools import product
from functools import reduce
import typer
from pvgisprototype.cli.typer_parameters import OrderCommands
from pydantic import BaseModel, ValidationError, conlist
from pydantic import ConfigDict
from pydantic import field_validator