Skip to content

Instantly share code, notes, and snippets.

View gpelouze's full-sized avatar

Gabriel Pelouze gpelouze

View GitHub Profile
@gpelouze
gpelouze / CAL_POINT-COLD-14STEP_SS_SL30_30.0S_FD.ipynb
Created July 19, 2022 16:09
CAL_POINT-COLD-14STEP_SS_SL30_30.0S_FD.ipynb
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.
@gpelouze
gpelouze / get_solo_image_coordinates.py
Last active July 11, 2022 16:31
get_solo_image_coordinates
from astropy import wcs
import numpy as np
def ang_to_pipi(a):
""" Convert any angle to the range ]-pi, pi]
Parameters
==========
a : float or astropy.units.Quantity
Angle to convert. If it has no quantity, assumes it is in radians.
@gpelouze
gpelouze / moab_queue.sh
Created March 5, 2021 12:43
Show moab queue and start time estimate for each job
qstat -a 1>&2 | grep -oP "^(\d+)(?=\.)" | xargs -n 1 showstart
include "%L"
<mu> <a> : "α" Greek_alpha
<mu> <A> : "Α" Greek_ALPHA
<mu> <b> : "β" Greek_beta
<mu> <B> : "Β" Greek_BETA
<mu> <g> : "γ" Greek_gamma
<mu> <G> : "Γ" Greek_GAMMA
<mu> <d> : "δ" Greek_delta
<mu> <D> : "Δ" Greek_DELTA
import numpy as np
import IPython
def _num_formatter(num):
return "{:_}".format(num)
def _ipython_formatter(arg, p, cycle):
p.text(_num_formatter(arg))
@gpelouze
gpelouze / ads_bookmarklet.js
Created July 13, 2019 14:56
NASA ADS smart bookmarklet
/* Smart bookmarklet for NASA ADS (https://ui.adsabs.harvard.edu)
Author: G. Pelouze
# Installation (Works with Firefox, probably elsewhere too)
- Create a new bookmark
- paste the minified js (last line of this snippet) in the 'location' field
- type 'ads' in the 'keyword' field (or any other keyword)
import difflib
def fits_headers_diff(h1, h2, print_diff=False):
''' Determine the difference between two FITS headers
Parameters
==========
h1, h2 : astropy.io.fits.header.Header
The two FITS headers to compare
print_diff : bool (default: False)
If True, print the diff in addition to returning it.
@gpelouze
gpelouze / aggressive_autoscale.py
Last active February 21, 2019 08:17
Autoscale a matplotlib axis taking into account the limit along the other axis
import numpy as np
def aggressive_autoscale(axes, axis, margin=0.1):
''' Autoscale an axis taking into account the limit along the other axis.
Example use case: set the x-limits, then autoscale the y-axis using only
the y-data within the x-limits. (Matplotlib's behaviour would be to use the
full y-data.)
Parameters