This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pathlib import Path | |
import yaml | |
here = Path(__file__).resolve().parent | |
with open(here / './config.yaml', 'r') as stream: | |
config_dict = yaml.safe_load(stream) | |
class Struct: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
fig = go.Figure() | |
xdata = [(1 - 1/i) for i in range(1, 15)] | |
fig.add_trace(go.Scatter( | |
x=xdata, y=len(xdata)*[0], mode='markers', marker_size=10, marker_color='red' | |
)) | |
fig.update_xaxes(showgrid=False) | |
fig.update_yaxes(showgrid=False, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
from time import sleep | |
import numpy as np | |
fig = go.FigureWidget() | |
# Display in Jupyter: | |
display(fig) | |
sleep(.25) | |
fig.add_trace(go.Scatter(x=[0], y=[0])) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from astropy.modeling.polynomial import SIP | |
import itertools | |
from astropy.io.fits.header import Header | |
def get_sip_coeffs(hdr: Header , kind='A') -> dict: | |
"""Return a SIP polynomial coefficients for the selected | |
coefficient type: (A, B, AP, BP). | |
Parameters | |
---------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Science | |
import numpy as np | |
from astropy.units import Unit | |
# Notebook | |
from IPython.display import Markdown | |
from IPython.core.interactiveshell import InteractiveShell | |
InteractiveShell.ast_node_interactivity = "all" | |
# Handy functions |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import plotly.graph_objects as go | |
import numpy as np | |
from scipy.special import gamma | |
from pathlib import Path | |
here = Path(__file__).parent | |
filename = Path(__file__).stem | |
xdata = np.linspace(-5, 5, 1000) | |
ydata = gamma(xdata) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
convert -resize 800x800 -delay 25 -loop 0 image-file-*.png animation.gif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from time import sleep, time | |
import numpy as np | |
from astropy import wcs | |
w = wcs.WCS(naxis=2) | |
w.wcs.ctype = ["RA---SIN","DEC--SIN"] | |
w.wcs.cdelt = (6.2/3600, 6.2/3600) | |
w.wcs.crval = (30, 60) | |
w.wcs.crota = (0, 15) | |
# ---------------------------------------- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Author: Miladious | |
Latest Modification Date: Oct 11, 2019 | |
About: | |
Creating a publication quality figure using matplotlib requires a lot of tweaks. | |
In this gist, I show the main tweaks for creating publication quality plots. | |
This is an example how one would plot astronomical images in python. | |
Feel free to modify to your field's standards. | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# https://gist.github.com/Miladiouss/332b21e3c9d82ca2085b1396641cc80d | |
#----------------------------------------------------------- | |
# IPython | |
from IPython.core.interactiveshell import InteractiveShell | |
from IPython.display import clear_output | |
InteractiveShell.ast_node_interactivity = "all" | |
from IPython import display | |
#----------------------------------------------------------- | |
# Scientific |
NewerOlder