Skip to content

Instantly share code, notes, and snippets.

View AdrianoPereira's full-sized avatar
🎯
Focusing

Adriano Almeida AdrianoPereira

🎯
Focusing
View GitHub Profile
datetime final_wind_speed
2017-01-01 9.417031249999999
2017-01-02 9.108577221609844
2017-01-03 8.47080858572422
2017-01-04 9.411196253622135
2017-01-05 9.50585397785974
2017-01-06 9.218035502168386
2017-01-07 9.892552083333333
2017-01-08 9.183578125
2017-01-09 8.117958333333334
# Read the GRIB file into a DataFrame
grib_df = spark.read.format("binaryFile").option("pathGlobFilter", "*.grb").load("/path/to/grib/file.grb")
# Define a function to read the GRIB file using cfgrib
def read_grib_file(file_path):
with cfgrib.open_file(file_path) as ds:
# Read the GRIB data into a pandas DataFrame
grib_data = ds.to_dataframe()
return grib_data
@AdrianoPereira
AdrianoPereira / hand-on-data-science-weather-dataset.ipynb
Created April 19, 2023 16:38
hand-on-data-science-weather-dataset
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
np.random.seed(42)
pixels = ['64-pixel', '96-pixel', '128-pixel', '160-pixel']
layers = ['1-layer', '2-layers', '3-layers', '4-layers', '5-layers']
rmse = np.random.uniform(1.5, 2.5, 20).reshape((4, 5))
rmse2 = np.random.uniform(0.5, .9, 20).reshape((4, 5))
dpi = 96
xmonitor = np.round(1366 * 80 / 100)/dpi
Call function to create file...
File created
Reading file...
Variables...
Variable scalarVar:
Shape: (1,)
Value: [--]
Variable arrayVar:
Shape: (100,)
Value: [ 1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14.
import numpy as np
import netCDF4 as nc
FILENAME = "./ex001.nc" # File name
DIM1 = 1 # Scalar dimension
DIM2 = 100 # 1-D Array dimension
DIM3 = 20 # Rows matrix
DIM4 = 100 # Columns matrix
import gzip as gz
import matplotlib.pyplot as plt
from string import Template
from matplotlib.colors import Normalize
from metpy.plots import colortables as ct
import os
import numpy as np
import pandas as pd
from matplotlib.colorbar import make_axes
import datetime as dt
import matplotlib.pyplot as plt
from matplotlib.colors import Normalize
from metpy.plots import colortables as ct
import os
import numpy as np
import cartopy.crs as ccrs
import cartopy.feature as cfeature
from matplotlib.colorbar import make_axes
from cartopy.mpl.gridliner import LONGITUDE_FORMATTER, LATITUDE_FORMATTER
import gzip as gz
import os
from bs4 import BeautifulSoup
import json
def get_filepaths(path):
return [os.path.join(path, talk) for talk in os.listdir(path)]
def extract_questions_talk(filepath):
@AdrianoPereira
AdrianoPereira / download_goamzon_data.py
Last active August 21, 2020 00:43
Script to download GoAmazon data from ARM
import numpy as np
from goamazondownloader import SBandRadar
import tarfile as tar
import os
'''
Before to running, install the `goamazondownloader` library using the command
below: