This file contains hidden or 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 sys | |
| import numpy as np | |
| def reformat_txt(inname, outname): | |
| """ | |
| Function that converts txt-file with dyn. spectra in format: | |
| https://www.dropbox.com/sh/l6kr87oxsxpg367/AACbXZNX4KU1KNEYWjphKbhoa/FRB010724/ascii_files?dl=0 | |
| #ch0 t1 value |
This file contains hidden or 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 joblib | |
| import os | |
| cachedir = 'cache' | |
| if not os.path.isdir(cachedir): os.mkdir(cachedir) | |
| mem = joblib.Memory(cachedir=cachedir, verbose=True) | |
| @mem.cache | |
| def my_long_function(i): | |
| return i + i |
This file contains hidden or 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 | |
| vint = np.vectorize(int) | |
| vround = np.vectorize(round) | |
| def de_disperse(image, nu_0, d_nu, d_t, dm_values): | |
| """ | |
| De-disperse dynamical spestra with grid of user specifies values of DM. |
This file contains hidden or 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 collections import OrderedDict, Callable | |
| class DefaultOrderedDict(OrderedDict): | |
| # Source: http://stackoverflow.com/a/6190500/562769 | |
| def __init__(self, default_factory=None, *a, **kw): | |
| if (default_factory is not None and | |
| not isinstance(default_factory, Callable)): | |
| raise TypeError('first argument must be callable') | |
| OrderedDict.__init__(self, *a, **kw) | |
| self.default_factory = default_factory |
This file contains hidden or 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 os | |
| import numpy as np | |
| from components import CGComponent, EGComponent | |
| from from_fits import (create_uvdata_from_fits_file, | |
| create_image_from_fits_file, | |
| create_clean_image_from_fits_file) | |
| from model import Model | |
| from spydiff import clean_difmap | |
| from data_io import get_fits_image_info | |
| from utils import mas_to_rad, degree_to_rad |
This file contains hidden or 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
| def clean_difmap(fname, outfname, stokes, mapsize_clean, path=None, | |
| path_to_script=None, mapsize_restore=None, beam_restore=None, | |
| outpath=None, shift=None, show_difmap_output=False): | |
| """ | |
| Map self-calibrated uv-data in difmap. | |
| :param fname: | |
| Filename of uv-data to clean. | |
| :param outfname: | |
| Filename with CCs. |
This file contains hidden or 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
| ! final_clean_rms -- revised version of old 'final_clean' script | |
| ! | |
| ! Version: 2011_05_09 | |
| ! Change Log: | |
| ! 2011_05_09 - limit maximum clean iter in natural clean to 500 | |
| ! | |
| ! Script revised -- May 2011 by D. Homan to improve stopping | |
| ! criteria and not overclean images. See 'deep_map_residual' | |
| ! macro below for how this works in detail. The idea is to | |
| ! compare the residual map rms in the frame to a target RMS which |
This file contains hidden or 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 cfx import CFX | |
| from utils import find_file | |
| from raw_data import M5 | |
| cfx_file = '/home/ilya/code/frb/data/cfx/RADIOASTRON_RAKS12ER_L_20151105T130000_ASC_V1.cfx' | |
| cfx = CFX(cfx_file) | |
| cfx_data = cfx.parse_cfx('raks12er') | |
| fname = 'rk12er_tr_no0001' | |
| params = cfx_data[fname] |
This file contains hidden or 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
| def create_mask(shape, region): | |
| """ | |
| Function that creates rectangular or circular or elliptic gaussian mask. | |
| :param shape: | |
| Shape of the image. | |
| :param region: | |
| Tuple (blc[0], blc[1], trc[0], trc[1],) or (center[0], center[1], r, | |
| None,) or (center[0], center[1], bmaj, e, bpa). Where ``bpa`` [rad]. | |
This file contains hidden or 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 os | |
| import json | |
| import time | |
| import numpy as np | |
| import scipy as sp | |
| import corner | |
| from uv_data import UVData | |
| from spydiff import import_difmap_model | |
| from model import Model | |
| from stats import LnLikelihood |