repo
stringlengths
2
99
file
stringlengths
13
225
code
stringlengths
0
18.3M
file_length
int64
0
18.3M
avg_line_length
float64
0
1.36M
max_line_length
int64
0
4.26M
extension_type
stringclasses
1 value
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/hyper_b/plot.py
import numpy as np import matplotlib.pyplot as plt from V_plot import * from u_plot import * from plot_trajectory import * # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True font_size = 15 A = torch.load('./data/hyper_b/data.pt')[:,9:14,...
2,394
26.848837
106
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/plot_loss.py
import numpy as np import matplotlib.pyplot as plt import torch import pylustrator pylustrator.start() import seaborn as sns sns.set_theme(style="whitegrid") L1 = torch.load('./data/harmonic/loss_icnn.pt')[2:] # delete large first tow numbers L2 = torch.load('./data/harmonic/loss_quad.pt') L3 = torch.load('./data/har...
3,889
45.86747
181
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/AS.py
import torch import torch.nn.functional as F import timeit class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Linear(n_hidden,n_hidd...
2,766
26.39604
143
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/generate.py
import numpy as np import math import torch import numpy as np import timeit from AS import * from Control_Nonlinear_Icnn import * start = timeit.default_timer() # Harmonic linear oscillator model = Net(D_in,H1,D_out) # Generate trajectory with nonlinaer AS control def algo2(z,X,N,dt): model = Net(D_in,H1,D_out...
2,835
33.585366
113
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/ES_ICNN.py
import torch import torch.nn.functional as F import timeit from hessian import hessian from hessian import jacobian from Control_Nonlinear_Icnn import * # Drift function def harmonic(x): y = [] beta = 0.5 for i in range(0,len(x)): f = [x[i,1],-x[i,0]-2*beta*x[i,1]] y.append(f) y = to...
2,972
26.527778
142
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/ES_Quadratic.py
import torch import torch.nn.functional as F import timeit from hessian import hessian from hessian import jacobian class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hid...
3,376
26.016
142
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/plot.py
import numpy as np import matplotlib.pyplot as plt import torch import matplotlib matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' matplotlib.rcParams['text.usetex'] = True import sys sys.path.append('./data/harmonic') ''' Data is dictionary {'X','Y','Z','W'},corresponds to 20 sample trajectories unde...
11,933
39.317568
114
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/table1.py
import numpy as np import torch data = torch.load('./data/harmonic/data_long.pt') # Calculate the data in table1 def L2_norm(st,a): Y = data[st][torch.tensor([0,1,3,4,5,6,7,8,9,10,11,13,14,15,16,17,18,19]),:,:] Y = Y.detach().numpy() X = np.linalg.norm(Y,axis=2) Z = np.mean(X,0) index = np.where(Z...
513
24.7
83
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/Neural Stochastic Control/harmonic/Control_Nonlinear_Icnn.py
import torch import torch.nn as nn import torch.nn.functional as F class ICNN(nn.Module): def __init__(self, input_shape, layer_sizes, activation_fn): super(ICNN, self).__init__() self._input_shape = input_shape self._layer_sizes = layer_sizes self._activation_fn = activation_fn ...
3,754
34.424528
122
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/functions.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse import matplotlib.pyplot as plt colors = [ [233/256, 110/256, 236/256], # #e96eec # [0.6, 0.6, 0.2], # olive # [0.5333333333333333, 0.13333333333333333, 0.3333333333333333], # wine [255/255, 165/255, 0], ...
2,097
32.301587
89
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/run.py
import numpy as np from scipy import integrate import torch import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint from functions import * def f(x,u=0): a, b, c = 1, 1, 1 U2 = np.array([0.5, 0.74645887, 1.05370735, 0.38154169, 1.68833014, 0.83746371]) x1, x2, x3, x4, ...
4,155
29.335766
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/NODE.py
# import sys # sys.path.append('./neural_sde/NODE') import argparse import time import numpy as np import torch import torch.nn as nn import torch.optim as optim parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--method', type=str, choices=['dopri5', 'adams'], default='dopri5') parser.add_argument('...
4,670
31.213793
118
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/model_free/NSC_train.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--N', type=float, default=1000) parser.add_argument('--num', type=float, default=6) parser.add_argument('--lr', type=float, default=0.05) args = parser.parse_a...
4,004
31.04
153
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/multiple_k/AS.py
import torch import torch.nn.functional as F import timeit import math class Net(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(Net, self).__init__() torch.manual_seed(2) self.layer1 = torch.nn.Linear(n_input, n_hidden) self.layer2 = torch.nn.Linear(n_h...
1,716
21.012821
72
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/multiple_k/functions.py
import numpy as np import math import torch import timeit from scipy import integrate import matplotlib.pyplot as plt start = timeit.default_timer() np.random.seed(1) class Net(torch.nn.Module): def __init__(self, n_input, n_hidden, n_output): super(Net, self).__init__() torch.manual_seed(2) ...
6,281
26.432314
129
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/multiple_k/plot_appendix.py
import numpy as np import matplotlib.pyplot as plt import torch # import matplotlib # matplotlib.rcParams['font.sans-serif'] = 'NSimSun,Times New Roman' # matplotlib.rcParams['text.usetex'] = True def plot_grid(): plt.grid(b=True, which='major', color='gray', alpha=0.6, linestyle='dashdot', lw=1.5) # minor gr...
2,306
30.60274
102
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/mixed_control/functions.py
import numpy as np from scipy import integrate import torch import torch.nn as nn import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint colors = [ [233/256, 110/256, 236/256], # #e96eec # [0.6, 0.6, 0.2], # olive # [0.5333333333333333, 0.13333333333333333, 0.3333333...
2,307
31.507042
89
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/mixed_control/run.py
import numpy as np from scipy import integrate import torch import matplotlib.pyplot as plt import math import timeit from scipy.integrate import odeint from functions import * from cvxopt import solvers,matrix def f(x,u=0): u,v = x G = 9.81 # gravity L = 0.5 # length of the pole m = 0.15 # ball m...
4,956
29.598765
127
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/mixed_control/NSC_train.py
import torch import torch.nn.functional as F import numpy as np import timeit import argparse parser = argparse.ArgumentParser('ODE demo') parser.add_argument('--N', type=float, default=1000) parser.add_argument('--num', type=float, default=2) parser.add_argument('--lr', type=float, default=0.05) args = parser.parse_a...
3,379
28.137931
153
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/comparison/lqr.py
import numpy as np from cvxopt import solvers,matrix import matplotlib.pyplot as plt import torch def harmonic(n,dt): x0 = np.array([2.0,2.0]) X = np.zeros([n,2]) X[0,:]=x0 z = np.random.normal(0, 1, n) for i in range(n-1): x1,x2 = X[i,:] X[i+1,0] = x1 + (x2-4.45*x1-0.09*x2)*dt ...
662
21.1
83
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/comparison/riccati.py
import numpy as np from matplotlib import pyplot as plt import seaborn as sns #由题目定义矩阵 A = np.matrix([[0, 1.0], [-1.0, -1.0]]) AT = np.matrix([[0,-1.0], [1, -1.0]]) B = np.matrix([[1.0,0.0], [0.0,1.0]]) BT = np.matrix([[1.0,0.0], [0.0,1.0]]) F = np.matrix([[1, 0], [0, 2]]) Q = np.matrix([[20.0, 0.0], [0.0, 20.0]]) R =...
1,075
22.911111
62
py
Neural-Stochastic-Control
Neural-Stochastic-Control-main/code_rebuttal/comparison/run.py
import numpy as np from cvxopt import solvers,matrix import matplotlib.pyplot as plt import torch import seaborn as sns class ControlNet(torch.nn.Module): def __init__(self,n_input,n_hidden,n_output): super(ControlNet,self).__init__() torch.manual_seed(2) self.layer1=torch.nn.Linear(n_inp...
10,101
40.572016
116
py
gsdmm
gsdmm-master/setup.py
from setuptools import setup VERSION=0.1 INSTALL_REQUIRES = [ 'numpy' ] setup( name='gsdmm', packages=['gsdmm'], version=0.1, url='https://www.github.com/rwalk/gsdmm', author='Ryan Walker', author_email='[email protected]', description='GSDMM: Short text clustering ', license='MIT...
363
18.157895
48
py
gsdmm
gsdmm-master/gsdmm/mgp.py
from numpy.random import multinomial from numpy import log, exp from numpy import argmax import json class MovieGroupProcess: def __init__(self, K=8, alpha=0.1, beta=0.1, n_iters=30): ''' A MovieGroupProcess is a conceptual model introduced by Yin and Wang 2014 to describe their Gibbs sampl...
7,818
37.141463
115
py
gsdmm
gsdmm-master/gsdmm/__init__.py
from .mgp import MovieGroupProcess
34
34
34
py
gsdmm
gsdmm-master/test/__init__.py
0
0
0
py
gsdmm
gsdmm-master/test/test_gsdmm.py
from unittest import TestCase from gsdmm.mgp import MovieGroupProcess import numpy class TestGSDMM(TestCase): '''This class tests the Panel data structures needed to support the RSK model''' def setUp(self): numpy.random.seed(47) def tearDown(self): numpy.random.seed(None) def comput...
2,638
24.621359
94
py
MixLacune
MixLacune-main/process-lacunes.py
# -*- coding: utf-8 -*- import os import torch import torchvision import numpy as np from torch.utils.data import Dataset, DataLoader from torchvision import transforms, utils import SimpleITK as sitk import glob import torch.nn as nn import nibabel as nib import shutil device = torch.device('cuda' if torch.cud...
21,262
36.173077
155
py
MixLacune
MixLacune-main/process.py
import SimpleITK import numpy as np from evalutils import SegmentationAlgorithm from evalutils.validators import UniqueImagesValidator # added imports #import tensorflow as tf from typing import Tuple, List from pathlib import Path import re import subprocess from evalutils.io import (ImageLoader, SimpleITKLoader)...
5,806
40.776978
121
py
slfrank
slfrank-master/tests/test_linop.py
import unittest import numpy as np import numpy.testing as npt from linop import DiagSum if __name__ == '__main__': unittest.main() class TestLinop(unittest.TestCase): def test_DiagSum(self): X = np.array([[1, 2], [3, 4]]) A = DiagSum(2) npt.assert_allclose(A(X), [3, 5, 2])
311
18.5
44
py
slfrank
slfrank-master/slfrank/design.py
import numpy as np import cvxpy as cp import sigpy as sp import sigpy.mri.rf as rf import scipy.sparse from . import linop, prox, transform def design_rf(n=64, tb=4, ptype='ex', d1=0.01, d2=0.01, phase='linear', oversamp=15, lamda=None, solver='PDHG', max_iter=None, sigma=None, verbose=Tru...
13,848
35.253927
152
py
slfrank
slfrank-master/slfrank/linop.py
import sigpy as sp import numpy as np import numba as nb class DiagSum(sp.linop.Linop): """A Linop that sums along the diagonals of a matrix. Args: n (int): width of matrix. """ def __init__(self, n): self.n = n super().__init__((2 * n - 1, ), (n, n)) def _apply(self...
1,294
18.923077
68
py
slfrank
slfrank-master/slfrank/transform.py
import numpy as np def hard_pulse(a, b, b1): """Apply hard pulse rotation to input magnetization. Args: theta (complex float): complex B1 value in radian. Returns: array: magnetization array after hard pulse rotation, in representation consistent with input. """ c = ...
3,163
23.71875
70
py
slfrank
slfrank-master/slfrank/plot.py
import numpy as np import matplotlib.pyplot as plt import sigpy.mri.rf as rf from . import transform from . import design def plot_slr_pulses(pulse_slr, pulse_slfrank, m=1000, ptype='ex', phase='linear', omega_range=[-np.pi, np.pi], tb=4, d1=0.01, d2=0.01, ...
6,895
40.293413
94
py
slfrank
slfrank-master/slfrank/__init__.py
from .design import * from .linop import * from .prox import * from .transform import * from .plot import *
108
17.166667
24
py
slfrank
slfrank-master/slfrank/prox.py
import sigpy as sp class Objective(sp.prox.Prox): def __init__(self, shape, lamda): self.lamda = lamda super().__init__(shape) def _prox(self, alpha, input): xp = sp.get_array_module(input) n = (len(input) - 1) // 2 output = input.copy() output[1, 0] += alpha ...
468
22.45
46
py
stistools
stistools-master/stistools/r_util.py
import os import os.path import copy NOT_APPLICABLE = 'n/a' def expandFileName(filename): """Expand environment variable in a file name. If the input file name begins with either a Unix-style or IRAF-style environment variable (e.g. $lref/name_dqi.fits or lref$name_dqi.fits respectively), this routi...
2,505
27.804598
78
py
stistools
stistools-master/stistools/basic2d.py
#! /usr/bin/env python import os import sys import getopt import glob import subprocess from stsci.tools import parseinput, teal __doc__ = """ Perform basic 2-D calibration of STIS data. Examples -------- In Python without TEAL: >>> import stistools >>> stistools.basic2d.basic2d("o66p01020_raw.fits", verbose=Tru...
12,134
30.437824
76
py
stistools
stistools-master/stistools/calstis.py
#! /usr/bin/env python import os import sys import getopt import glob import subprocess from stsci.tools import parseinput, teal __doc__ = """ Calibrate STIS data. The input raw files should be in the default directory. This is not always necessary, but it will always work. For spectroscopic data, if a path is sp...
7,287
27.46875
76
py
stistools
stistools-master/stistools/tastis.py
#! /usr/bin/env python from math import modf, sqrt import os import argparse from astropy.io import fits import numpy as np __doc__ = """ Analyze STIS target acquisition images. :func:`tastis` will print general information about each input target acquisition image, and will analyze both types of STIS target acquisi...
37,270
39.119483
90
py
stistools
stistools-master/stistools/inttag.py
#! /usr/bin/env python import numpy as np from astropy.io import fits import astropy.stats from astropy import units as u from astropy.time import Time from datetime import datetime as dt __doc__ = """ The task :func:`inttag` converts an events table of TIME-TAG mode STIS data into a raw, time-integrated ACCUM image....
16,741
39.148681
117
py
stistools
stistools-master/stistools/stisnoise.py
#!/usr/bin/env python import math from astropy.io import fits import numpy import numpy.fft as fft from scipy import ndimage from scipy import signal __version__ = '5.6 (2016-Mar-02)' def _median(arg): return numpy.sort(arg)[arg.shape[0]//2] def medianfilter(time_series, width): tlen = time_series.shape[...
12,097
36.80625
79
py
stistools
stistools-master/stistools/ctestis.py
from astropy.io import fits import numpy as np __doc__ = """ The purpose of this ctestis task is to correct signal levels of point-like sources in photometry tables measured from STIS CCD images for charge loss due to imperfect Charge Transfer Efficiency (CTE). The algorithm used to correct for CTE-induced signal loss...
10,161
35.163701
82
py
stistools
stistools-master/stistools/observation.py
from astropy.io import fits def initObservation(input, instrument, sci_num): """Construct an Observation object for the current mode. Parameters ---------- input: str The name of an input file. instrument: str Value of keyword INSTRUME, should be "COS" or "STIS" Returns ...
2,082
24.096386
71
py
stistools
stistools-master/stistools/gettable.py
import math import numpy as np from astropy.io import fits STRING_WILDCARD = "ANY" INT_WILDCARD = -1 def getTable(table, filter, sortcol=None, exactly_one=False, at_least_one=False): """Return row(s) of a table that match the filter. Rows that match every item in the filter (a dictionary of ...
5,092
30.245399
76
py
stistools
stistools-master/stistools/wavecal.py
#! /usr/bin/env python import os import sys import getopt import glob import subprocess import numpy.random as rn # used by mkRandomName from astropy.io import fits from stsci.tools import parseinput, teal """ Perform wavelength calibration of STIS data. Examples -------- In Python without TEAL: >>...
17,785
30.817531
79
py
stistools
stistools-master/stistools/doppinfo.py
#! /usr/bin/env python import sys import math import numpy as np from astropy.io import fits from . import observation from . import orbit __doc__ = """ This class computes Doppler shift information for each imset of a dataset. Keywords will be read from the science file and from the support file. The Doppler shift...
20,721
34.422222
87
py
stistools
stistools-master/stistools/x1d.py
#! /usr/bin/env python import os import sys import getopt import glob import subprocess from stsci.tools import parseinput, teal __doc__ = """ Extract 1-D spectrum. Examples -------- In Python without TEAL: >>> import stistools >>> stistools.x1d.x1d("o66p01020_flt.fits", output="test_x1d.fits", ... ...
13,036
28.697039
88
py
stistools
stistools-master/stistools/ocrreject.py
#! /usr/bin/env python import os import sys import getopt import glob import subprocess from stsci.tools import parseinput, teal __doc__ = """ Add STIS exposures, rejecting cosmic rays. Examples -------- In Python without TEAL: >>> import stistools >>> stistools.ocrreject.ocrreject("o3tt02020_flt.fits", ... ...
11,774
30.483957
77
py
stistools
stistools-master/stistools/__init__.py
from __future__ import absolute_import from .version import * from . import calstis from . import basic2d from . import ocrreject from . import wavecal from . import x1d from . import x2d from . import mktrace from . import sshift from . import stisnoise from . import wx2d from . import inttag from . import doppinfo f...
583
23.333333
69
py
stistools
stistools-master/stistools/radialvel.py
import numpy as N DEG_RAD = N.pi / 180. # degrees to radians ARCSEC_RAD = N.pi / (180.*3600.) # arcseconds to radians REFDATE = 51544.5 # MJD for 2000 Jan 1, 12h UT KM_AU = 1.4959787e8 # kilometers per astronomical unit SEC_DAY = 86400. # seconds per d...
7,261
30.034188
80
py
stistools
stistools-master/stistools/x2d.py
#! /usr/bin/env python import os import sys import getopt import glob import subprocess from stsci.tools import parseinput, teal __doc__ = """ Rectify 2-D STIS spectral data. Examples -------- In Python without TEAL: >>> import stistools >>> stistools.x2d.x2d("o66p01020_flt.fits", output="test_x2d.fits", ... ...
9,046
28.469055
81
py
stistools
stistools-master/stistools/wx2d.py
#! /usr/bin/env python import sys import os import os.path import math import numpy as N from scipy import signal as convolve from astropy.io import fits from . import gettable from . import wavelen from . import r_util __version__ = "1.3 (2016 Feb 24)" def wx2d(input, output, wavelengths=None, helcorr="", ...
33,439
31.720157
88
py
stistools
stistools-master/stistools/mktrace.py
#!/usr/bin/env python import numpy as np from astropy.io import fits import os.path from scipy import signal from scipy import ndimage as ni from stsci.tools import gfit, linefit from stsci.tools import fileutil as fu __doc__ = """ Refine a STIS trace table. - A trace is generated from the science file and a trace ...
13,184
30.694712
101
py
stistools
stistools-master/stistools/add_stis_s_region.py
#!/usr/bin/env python import glob import math import os import sys import argparse from astropy.io import fits from astropy.wcs import WCS import numpy as np import logging import pysiaf __doc__ = """ This script will calculate an S_REGION string for STIS data and assign it to the S_REGION keyword in the science d...
18,923
37.938272
112
py
stistools
stistools-master/stistools/wavelen.py
import numpy as N from . import evaldisp from . import gettable from . import radialvel from . import r_util DEG_RAD = N.pi / 180. # degrees to radians SPEED_OF_LIGHT = 299792.458 # km / s def compute_wavelengths(shape, phdr, hdr, helcorr): """Compute a 2-D array of wavelengths, o...
7,760
34.438356
78
py
stistools
stistools-master/stistools/sshift.py
#!/usr/bin/env python """ A Python module for aligning the spectra in different flat-fielded images of an IMSET. These files can then be combined with along-the-slit dithering to reject hot pixels and cosmic rays. The POSTARG2 keyword is used to determine the number of rows to be shifted. """ from astropy.io import ...
9,359
34.589354
93
py
stistools
stistools-master/stistools/evaldisp.py
def newton(x, coeff, cenwave, niter=4): """Return the wavelength corresponding to pixel x. The dispersion solution is evaluated iteratively, and the slope (dispersion) for Newton's method is determined numerically, using a difference in wavelength of one Angstrom. Note that the evalDisp in this ...
2,679
27.510638
72
py
stistools
stistools-master/stistools/orbit.py
import math from astropy.io import fits TWOPI = (math.pi * 2.0) SEC_PER_DAY = 86400.0 class HSTOrbit(object): """Orbital parameters. The public methods are getOrbitper and getPos. """ def __init__(self, spt): """Orbital parameters. Parameters ---------- spt: str ...
5,144
29.443787
71
py
stistools
stistools-master/stistools/defringe/_fit1d.py
# # This module reproduces much of the behaviour of IRAF 1-d fitting routines import math import numpy as np from scipy.interpolate import LSQUnivariateSpline def fit1d(x, y, weights=None, naverage=1, function="spline3", order=3, low_reject=3.0, high_reject=3.0, ...
10,262
30.194529
104
py
stistools
stistools-master/stistools/defringe/defringe.py
#! /usr/bin/env python import argparse from astropy.io import fits import datetime import os import textwrap import re import numpy as np from ..r_util import expandFileName # 4 bad detector pixel or beyond aperture # 8 data masked by occulting bar # 512 bad pixel in reference file sdqflags = 4 + 8 + 512 ...
8,739
39.841121
109
py
stistools
stistools-master/stistools/defringe/normspflat.py
#! /usr/bin/env python import os import numpy as np import warnings from astropy.io import fits from ..r_util import expandFileName from ..calstis import calstis from ._fit1d import fit1d # Keyword choices for calstis reduction: PERFORM = { 'ALL': ['DQICORR', 'BLEVCORR', 'BIASCORR', 'DARKCORR', 'FLATCORR', 'C...
16,395
45.05618
117
py
stistools
stistools-master/stistools/defringe/_findloc.py
import numpy as np from astropy.modeling import models, fitting # from lines 280 through 344 of mkfringeflat.cl def find_loc(input, low_frac=0.2, high_frac=0.8, low_line_frac=0.4): """Find the cross-dispersion location of the target spectrum. Parameters ---------- input: ndarray The input scie...
2,537
31.961039
78
py
stistools
stistools-master/stistools/defringe/mkfringeflat.py
#! /usr/bin/env python from astropy.io import fits from astropy.nddata.blocks import block_reduce import numpy as np import math import os from scipy.ndimage import shift from ._findloc import find_loc from ._response import response __version__ = 0.1 def mkfringeflat(inspec, inflat, outflat, do_shift=True, beg_shif...
19,503
38.885481
124
py
stistools
stistools-master/stistools/defringe/__init__.py
from .prepspec import prepspec from .normspflat import normspflat from .mkfringeflat import mkfringeflat from .defringe import defringe __doc__ = """ .. HST/STIS CCD Defringing Tools ----------------------------- - `prepspec` — Calibrate STIS CCD G750L or G750M spectrum before defringing - `normspflat` — N...
1,073
38.777778
123
py
stistools
stistools-master/stistools/defringe/prepspec.py
#! /usr/bin/env python import os import shutil import stat import re from astropy.io import fits from tempfile import mkdtemp import warnings from ..r_util import expandFileName from ..calstis import calstis def prepspec(inspec, outroot='./', darkfile=None, pixelflat=None, initguess=None): """Calibrate STIS CCD...
8,610
43.61658
121
py
stistools
stistools-master/stistools/defringe/_response.py
import math import numpy as np from astropy.io import fits from ._fit1d import fit1d def response(calibration_array, normalization_array, threshold=None, function="spline3", sample='*', naverage=2, order=10, low_reject=3.0, hig...
4,070
36.694444
90
py
stistools
stistools-master/tests/resources.py
"""HSTCAL regression test helpers.""" from six.moves import urllib import getpass import os import sys import math from io import StringIO import shutil import datetime from os.path import splitext from difflib import unified_diff import pytest import requests from astropy.io import fits from astropy.io.fits import FI...
12,883
33.449198
79
py
stistools
stistools-master/tests/test_tastis.py
import pytest from stistools.tastis import tastis from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestDoppinfo(BaseSTIS): input_loc = 'tastis' ref_loc = 'tastis' def test_header_update1(self, capsys): """ oc7w11viq # ACQ/PEAK-UP, RETURN-TO-BRIG...
30,805
61.869388
116
py
stistools
stistools-master/tests/conftest.py
"""Project default for pytest""" import os import pytest import re import crds from astropy.tests.helper import enable_deprecations_as_exceptions # Uncomment the following line to treat all DeprecationWarnings as exceptions enable_deprecations_as_exceptions() def pytest_addoption(parser): # Add option to run sl...
2,737
27.821053
108
py
stistools
stistools-master/tests/test_wx2d.py
import pytest from stistools.wx2d import wx2d from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestWx2d(BaseSTIS): input_loc = 'wx2d' ref_loc = 'wx2d' def test_wx2d_t1(self): """ Test for wx2d using rows parameter """ # Prepar...
1,251
24.04
76
py
stistools
stistools-master/tests/test_calstis.py
from stistools.calstis import calstis from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestCalstis(BaseSTIS): input_loc = 'calstis' ref_loc = 'calstis/ref' def test_ccd_imaging(self): """ This test is for calstis on CCD imaging data """ ...
4,115
30.419847
70
py
stistools
stistools-master/tests/test_basic2d.py
from stistools.basic2d import basic2d from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestBasic2d(BaseSTIS): input_loc = 'basic2d' ref_loc = 'basic2d/ref' def test_basic2d_lev1a(self): """ BASIC2D - stsdas/hst_calib/stis/basic2d: level 1a ...
5,491
40.606061
79
py
stistools
stistools-master/tests/test_doppinfo.py
from stistools.doppinfo import Doppinfo from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestDoppinfo(BaseSTIS): input_loc = 'doppinfo' ref_loc = 'doppinfo' def test_doppinfo_basic(self, capsys): """ Test stis.doppnfo.Doppinfo with defaults, no u...
6,932
51.522727
118
py
stistools
stistools-master/tests/test_ctestis.py
import numpy as np from stistools.ctestis import ctestis from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestCtestis(BaseSTIS): """ We need to add more tests for this """ input_loc = 'ctestis' ref_loc = 'ctestis' def test_single_value_ctestis(self, ...
4,270
38.546296
79
py
stistools
stistools-master/tests/test_mktrace.py
from stistools.mktrace import mktrace from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestMktrace(BaseSTIS): input_loc = 'mktrace' ref_loc = 'mktrace' atol = 1e-14 def test_mktrace_t1(self, capsys): """ This tests a basic usage of stis.mktr...
2,525
35.085714
96
py
stistools
stistools-master/tests/test_stisnoise.py
from stistools.stisnoise import stisnoise from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestStisnoise(BaseSTIS): input_loc = 'stisnoise' ref_loc = 'stisnoise' # Really should add some output and return array checks for these tests def test_stisnoise_t1(s...
1,364
25.764706
75
py
stistools
stistools-master/tests/test_ocrreject.py
from stistools.ocrreject import ocrreject from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestOcrreject(BaseSTIS): input_loc = 'ocrreject' ref_loc = 'ocrreject/ref' input_list = ["o58i01q7q_flt.fits", "o58i01q8q_flt.fits", "o58i01q9q_flt.fits"...
2,283
35.253968
78
py
stistools
stistools-master/tests/test_defringe.py
from stistools.defringe import normspflat, prepspec, mkfringeflat, defringe from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestDefringe(BaseSTIS): input_loc = 'defringe' def test_normspflat_g750l(self): """Compare normspflat output for a g750l spectrum"""...
4,310
29.359155
75
py
stistools
stistools-master/tests/__init__.py
0
0
0
py
stistools
stistools-master/tests/test_inttag.py
from stistools.inttag import inttag from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestInttag(BaseSTIS): input_loc = 'inttag' def test_accum_lores(self): """Compare accum image output for a single lowres imset""" self.get_data("input", "oddv01050_t...
3,152
36.535714
102
py
stistools
stistools-master/tests/Test_x1d.py
from stistools.x1d import x1d from .resources import BaseSTIS import pytest @pytest.mark.bigdata @pytest.mark.slow class TestX1d(BaseSTIS): input_loc = 'x1d' ref_loc = 'x1d/ref' def test_x1d(self): """ Basic x1d test, mostly using default parameters """ # Prepare input f...
606
21.481481
73
py
stistools
stistools-master/tests/helpers/utils.py
import os import re import requests from astropy.io import fits __all__ = ['cmp_fitshdr', 'cmp_gen_hdrkeywords', 'word_precision_check', 'abspath', 'download', 'check_url'] RE_URL = re.compile('\w+://\S+') default_compare = dict( ignore_keywords=['DATE', 'CAL_VER', 'CAL_VCS', 'CRDS_VER', 'C...
5,942
25.650224
79
py
stistools
stistools-master/tests/helpers/__init__.py
from .io import * from .utils import *
39
12.333333
20
py
stistools
stistools-master/tests/helpers/io.py
import copy import json import os import shutil from .utils import check_url, download UPLOAD_SCHEMA = {"files": [ {"pattern": "", "target": "", "props": None, "recursive": "false", "flat": "true", ...
3,882
31.630252
104
py
stistools
stistools-master/doc/source/conf.py
# -*- coding: utf-8 -*- # # stistools documentation build configuration file, created by # Warren Hack on Mon Oct 1 2012. # # This file is execfile()d with the current directory set to its containing dir. # # Note that not all possible configuration values are present in this # autogenerated file. # # All configuration...
6,974
31.746479
95
py
sst-macro
sst-macro-master/sstmac/sst_core/sstmacro.py
# Load module function in Python is changed # to look for a libmacro.so in LD_LIBRARY_PATH import sst import sst.macro smallLatency = "1ps" def getParam(params, paramName, paramNS=None): if not paramName in params: import sys if paramNs: sys.stderr.write("Missing parameter '%s' in namespace '%s'\n" % ...
10,780
31.570997
95
py
sst-macro
sst-macro-master/sstmac/skeletons/offered_load/traffic.py
def getVals(model): fileName = "%s.out" % model import re text = open(fileName).read() regexp = re.compile("throughput=\s+(\d+[.]\d+)") matches = regexp.findall(text) return map(float, matches) def absError(lvals, rvals): length = len(lvals) err = 0 for i in range(length): r = lvals[i] l = r...
1,195
19.271186
52
py
sst-macro
sst-macro-master/examples/snappr.py
import sst sst.setProgramOption("timebase", "100as") import sst.macro from sst.macro import Interconnect swParams = { "name" : "snappr", "router" : { "seed" : "42", "name" : "dragonfly_minimal", }, "link" : { "bandwidth" : "1.0GB/s", "latency" : "100ns", "credits" : "8KB", }, "logp" : {...
1,348
15.8625
41
py
sst-macro
sst-macro-master/examples/macrels.py
import sst sst.setProgramOption("timebase", "100as") import sst.macro from sst.macro import Interconnect swParams = { "name" : "logp", "out_in_latency" : "2us", } appParams = { "allocation" : "first_available", "indexing" : "block", "name" : "mpi_ping_all", "launch_cmd" : "aprun -n 80 -N 2", } memParams ...
894
14.431034
41
py
sst-macro
sst-macro-master/examples/pisces.py
import sst sst.setProgramOption("timebase", "100as") import sst.macro from sst.macro import Interconnect swParams = { "name" : "pisces", "arbitrator" : "cut_through", "mtu" : "4096", "router" : { "seed" : "42", "name" : "dragonfly_minimal", }, "link" : { "bandwidth" : "1.0GB/s", "latency" :...
1,507
16.333333
41
py
sst-macro
sst-macro-master/examples/sculpin.py
import sst sst.setProgramOption("timebase", "100as") import sst.macro from sst.macro import Interconnect swParams = { "name" : "sculpin", "router" : { "seed" : "42", "name" : "dragonfly_minimal", }, "link" : { "bandwidth" : "1.0GB/s", "latency" : "100ns", "credits" : "4KB", }, "logp" : ...
1,292
15.576923
41
py
sst-macro
sst-macro-master/python/snappr.py
# Load module function in Python is changed # to look for a libmacro.so in LD_LIBRARY_PATH import sst import sst.macro sst.setProgramOption("timebase", "100as") mtu = "4KB" small_latency = "1ps" nic_latency = "50ns" nic_bandwidth = "1.0GB/s" link_latency = "100ns" link_bandwidth = "1.0GB/s" topo_params = dict( nam...
4,372
26.161491
86
py
sst-macro
sst-macro-master/python/jobScheduler.py
from sst.merlin import * from sst.macro import * import sst.macro mtu = 1204 arb = "cut_through" buffer_size = "64KB" topo = topoTorus() params = sst.merlin._params params["torus:shape"] = "2x2x2"; params["torus:width"] = "1x1x1"; params["flit_size"] = "8B" params["link_bw"] = "10GB/s" params["link_lat"] = "100ns" ...
2,023
18.09434
69
py
sst-macro
sst-macro-master/python/arielShadowPuppet.py
import sst import os sst.setProgramOption("timebase", "100as") next_core_id = 0 next_network_id = 0 next_memory_ctrl_id = 0 clock = "2660MHz" memory_clock = "200MHz" coherence_protocol = "MESI" cores_per_group = 2 active_cores_per_group = 2 memory_controllers_per_group = 1 groups = 4 os.environ["OMP_NUM_THREADS"]=...
11,126
37.237113
232
py
sst-macro
sst-macro-master/python/emberDefaultParams.py
debug = 0 netConfig = { } networkParams = { "packetSize" : "2048B", "link_bw" : "4GB/s", "link_lat" : "40ns", "input_latency" : "50ns", "output_latency" : "50ns", "flitSize" : "8B", "buffer_size" : "14KB", } nicParams = { "detailedCompute.name" : "thornhill.SingleThread", "module" :...
2,076
30
66
py
sst-macro
sst-macro-master/python/emberLoadInfo.py
import sst import copy def calcNetMapId( nodeId, nidList ): if nidList == 'Null': return -1 pos = 0 a = nidList.split(',') for b in a: c = b.split('-') start = int(c[0]) stop = start if 2 == len(c): stop = int(c[1]) if nodeId >= sta...
10,427
28.047354
158
py
sst-macro
sst-macro-master/python/emberMacro.py
import sys,getopt import sst from sst.merlin import * from sst.macro import * #debug("simple_network") import emberLoadInfo from emberLoadInfo import * import random topoParams = { "name" : "torus", "geometry" : "2 2 2", } injLat = "1us" mtu="1KB" bufSize = "64KB" arb = "cut_through" macroParams = { "topolog...
2,968
17.32716
84
py
sst-macro
sst-macro-master/python/plotSwitches.py
import sys import os import numpy as np import matplotlib from mpl_toolkits.mplot3d import Axes3D from mpl_toolkits.mplot3d.art3d import Poly3DCollection, Line3DCollection import matplotlib.pyplot as plt def genFaces(Z): """should be numbered like so Z[0] = corner[:] Z[1] = corner + yDelta Z[2] = corner +...
2,832
22.608333
87
py
sst-macro
sst-macro-master/python/merlin.py
from sst.merlin import * from sst.macro import * import sst.macro mtu = 1204 arb = "cut_through" params = sst.merlin._params buffer_size = "64KB" topo = topoTorus() params["torus:shape"] = "2x2x2"; params["torus:width"] = "1x1x1"; params["flit_size"] = "8B" params["link_bw"] = "10GB/s" params["link_lat"] = "100ns...
1,699
17.085106
68
py