Skip to content

Instantly share code, notes, and snippets.

View Fernigithub's full-sized avatar
👋

Fernando Tentor Fernigithub

👋
View GitHub Profile
@Fernigithub
Fernigithub / update_info_data_layer.py
Created September 1, 2025 17:03
update data layer info
import pandas as pd
def generate_insert_queries_for_data_layers_v2(df, num_rows, column_mappings):
'''
Generate SQL insert queries from a DataFrame for the DataLayersInfo table.
It carries forward layer_category and layer_subcategory when they are not explicitly mentioned in every row.
:param df: DataFrame containing the data.
:param num_rows: Number of rows to generate queries for.
:param column_mappings: Dictionary mapping excel column names to table attribute names.
@Fernigithub
Fernigithub / get_substation_capacity.py
Created August 8, 2025 11:34
get_minmax_capacity
import os
import psycopg2
import geopandas as gpd
import rasterio
import numpy as np
from rasterio.features import rasterize, shapes
from rasterio.transform import from_bounds
from sqlalchemy import create_engine
from dotenv import load_dotenv
from skimage import measure
@Fernigithub
Fernigithub / reshape_parcel_rules.ipynb
Created May 13, 2025 20:03
reshape parcels rules
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Fernigithub
Fernigithub / IDW_interpolation.py
Created August 27, 2024 14:04
IDW interpoltation
import geopandas as gpd
import numpy as np
from scipy.spatial import cKDTree
from scipy.ndimage import gaussian_filter
from osgeo import gdal, osr, ogr
from shapely.geometry import Point
from matplotlib.pyplot import imshow, show, colorbar
def scale(im, nR, nC):
nR0 = len(im) # source number of rows
@Fernigithub
Fernigithub / LL15_DUL_layers_transf.py
Last active January 10, 2024 13:20
LL15_DUL_layer_transforation
df_90_sand = pd.DataFrame({'Depth': [20,40,60,80,100,120,140,160,180,200],
'LL15': [0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04,0.04],
'DUL': [0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12,0.12]})
df_65_sand = pd.DataFrame({'Depth': [20,40,60,80,100,120,140,160,180,200],
'LL15': [0.09,0.09,0.09,0.09,0.084,0.084,0.084,0.08,0.08,0.08],
'DUL': [0.22,0.22,0.22,0.22,0.208,0.208,0.208,0.2,0.2,0.2]})
df_70_sand = pd.DataFrame({'Depth': [20,40,60,80,100,120,140,160,180,200],
@Fernigithub
Fernigithub / i18n.md
Last active January 19, 2023 21:12
i18n
@Fernigithub
Fernigithub / streamlit_center_text.py
Created December 12, 2022 11:00 — forked from chandraseta/streamlit_center_text.py
Center text for Streamlit with optional container
import streamlit as st
from streamlit.delta_generator import DeltaGenerator
def display_centered_text(text: str, container: Optional[DeltaGenerator] = None):
if container is not None:
container.markdown(
f"<div style='text-align: center;'>{text}</div>",
unsafe_allow_html=True)
@Fernigithub
Fernigithub / data_format_px_line.py
Created August 10, 2022 18:37
date format plottly express line
# imports
import pandas as pd
import plotly.graph_objects as go
from datetime import datetime
import plotly.express as px
# data
open_data = [33.0, 33.3, 33.5, 33.0, 34.1]
high_data = [33.1, 33.3, 33.6, 33.2, 34.8]
low_data = [32.7, 32.7, 32.8, 32.6, 32.8]