Skip to content

Instantly share code, notes, and snippets.

View arjunsavel's full-sized avatar

Arjun Savel arjunsavel

View GitHub Profile
"""
uses a callback function to use a tqdm progress bar with multiprocessing.
"""
def func(arg):
return
def update_pbar(arg):
"""
Updates a tqdm progress bar. kind of annoying to leave it as referencing a global — might want to wrap this in a class.
@arjunsavel
arjunsavel / gcm_wind_vis.py
Last active July 19, 2022 15:55
plots GCM wind maps at the terminator.
import matplotlib.pyplot as plt
import matplotlib
# CHANGE: these planet params
PERIOD = 1.8 # days
Rp = 1.8 * 69.911e6 # meters
def calc_los(frame):
"""
calculates LOS velocity everywhere. eq 4 of harada+21
@arjunsavel
arjunsavel / t_p_vis.py
Last active October 9, 2023 15:31
Visualize the temperature--pressure structure of a 3D GCM.
"""
Script to plot 3D T-P profiles. Anything that should be changed is noted with CHANGE.
author: @arjunsavel
"""
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib.cm as cm
import matplotlib
@arjunsavel
arjunsavel / download_vizier.py
Created June 26, 2022 16:58
Download data from VizieR.
import pandas as pd
from astroquery.utils.tap.core import TapPlus
from urllib.error import HTTPError
VIZIER_TAP_URL = 'http://TAPVizieR.u-strasbg.fr/TAPVizieR/tap'
viz = TapPlus(url=VIZIER_TAP_URL)
table = "J/AJ/161/63/table3" # change the table
import numpy as np
from tqdm import tqdm
import matplotlib.pyplot as plt
from scipy.interpolate import interp2d
import pandas as pd
##### CHANGE this to your absolute file path to your EOS file! #####
eos_filename = 'RT_3D_Transmission_Code/Data/eos_solar_gas_full_hires.dat'
##### CHANGE this to your absolute file path to your GCM file! #####
@arjunsavel
arjunsavel / tqdm_import.py
Created October 20, 2021 15:23
Not sure if tqdm is installed? Catch an ImportError and just return an iterator!
try:
from tqdm import tqdm
except ImportError:
print(
"tqdm is not installed on this system, \
so progress bars will be unavailable. \
If you would like the progress bar feature, \
please see the tqdm installation docs: \
https://github.com/tqdm/tqdm#installation"
)
@arjunsavel
arjunsavel / plot_opacities.py
Last active December 11, 2023 16:00
Quick code to extract wavelength vs. opacity from an opacity file.
import numpy as np
import matplotlib.pyplot as plt
try:
from tqdm import tqdm
except ImportError:
print(
"tqdm is not installed on this system, \
so progress bars will be unavailable. \
If you would like the progress bar feature, \