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 torchvision | |
import torchvision.transforms as transforms | |
from torchvision.datasets import CIFAR10 | |
from torch.utils.data import Dataset, DataLoader | |
import numpy as np | |
# Transformations | |
RC = transforms.RandomCrop(32, padding=4) | |
RHF = transforms.RandomHorizontalFlip() | |
RVF = transforms.RandomVerticalFlip() |
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
import numpy as np | |
from pathlib import Path | |
# AstroPy | |
import astropy | |
from astropy.coordinates import SkyCoord, GCRS, ICRS, GeocentricTrueEcliptic, Galactic | |
import astropy.units as u | |
from astropy.io import fits | |
from astropy.wcs import WCS |
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
import numpy as np | |
from matplotlib import pyplot as plt | |
import torch | |
class HistogramTransform(object): | |
""" | |
Transforms the distribution of the input tensor to match that | |
of the list of template histograms corresponding to each channel. | |
NewerOlder