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 |
|---|---|---|---|---|---|---|
RAML | RAML-master/incremental/datasets/.ipynb_checkpoints/cityscapes_novel-checkpoint.py | import json
import os
from collections import namedtuple
from matplotlib import set_loglevel
import torch
import torch.utils.data as data
from PIL import Image
import numpy as np
import matplotlib.pyplot as plt
from torchvision import transforms
class Cityscapes_Novel(data.Dataset):
"""Cityscapes <http://www.ci... | 8,742 | 48.39548 | 168 | py |
RAML | RAML-master/incremental/network/_deeplab.py | import torch
from torch import nn
from torch.nn import functional as F
from .utils import _SimpleSegmentationModel, _SimpleSegmentationModel_embedding, _SimpleSegmentationModel_embedding_self_distillation,_SimpleSegmentationModel_Metric
__all__ = ["DeepLabV3"]
class DeepLabV3(_SimpleSegmentationModel):
"""
... | 8,740 | 39.281106 | 165 | py |
RAML | RAML-master/incremental/network/modeling.py | from PIL.Image import NONE
from .utils import IntermediateLayerGetter, DeepLabHeadV3Plus, DeepLabHead, DeepLabHeadV3Plus_Metric
from ._deeplab import DeepLabV3, DeepLabV3_embedding, DeepLabV3_embedding_self_distillation, DeepLabV3_metric
from .backbone import resnet
from .backbone import mobilenetv2
def _segm_resnet(n... | 8,134 | 44.194444 | 194 | py |
RAML | RAML-master/incremental/network/utils.py | from re import M
import torch
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from collections import OrderedDict
import json
class DeepLabHeadV3Plus_Metric(nn.Module):
def __init__(self, in_channels, low_level_channels, num_classes, aspp_dilate=[12, 24, 36], finetune=False):
super... | 21,245 | 39.701149 | 136 | py |
RAML | RAML-master/incremental/network/__init__.py | from .modeling import *
from .utils import convert_to_separable_conv | 68 | 33.5 | 44 | py |
RAML | RAML-master/incremental/network/backbone/resnet.py | import torch
import torch.nn as nn
#from torchvision.models.utils import load_state_dict_from_url
from torch.hub import load_state_dict_from_url
__all__ = ['ResNet', 'resnet18', 'resnet34', 'resnet50', 'resnet101',
'resnet152', 'resnext50_32x4d', 'resnext101_32x8d',
'wide_resnet50_2', 'wide_resne... | 13,621 | 38.598837 | 107 | py |
RAML | RAML-master/incremental/network/backbone/mobilenetv2.py | from torch import nn
#from torchvision.models.utils import load_state_dict_from_url
from torch.hub import load_state_dict_from_url
import torch.nn.functional as F
__all__ = ['MobileNetV2', 'mobilenet_v2']
model_urls = {
'mobilenet_v2': 'https://download.pytorch.org/models/mobilenet_v2-b0353104.pth',
}
def _mak... | 6,970 | 35.883598 | 123 | py |
RAML | RAML-master/incremental/network/backbone/__init__.py | from . import resnet
from . import mobilenetv2
| 47 | 15 | 25 | py |
RAML | RAML-master/incremental/network/.ipynb_checkpoints/utils-checkpoint.py | from re import M
import torch
import torch.nn as nn
import numpy as np
import torch.nn.functional as F
from collections import OrderedDict
import json
class DeepLabHeadV3Plus_Metric(nn.Module):
def __init__(self, in_channels, low_level_channels, num_classes, aspp_dilate=[12, 24, 36], finetune=False):
super... | 21,245 | 39.701149 | 136 | py |
RAML | RAML-master/incremental/network/.ipynb_checkpoints/_deeplab-checkpoint.py | import torch
from torch import nn
from torch.nn import functional as F
from .utils import _SimpleSegmentationModel, _SimpleSegmentationModel_embedding, _SimpleSegmentationModel_embedding_self_distillation,_SimpleSegmentationModel_Metric
__all__ = ["DeepLabV3"]
class DeepLabV3(_SimpleSegmentationModel):
"""
... | 8,740 | 39.281106 | 165 | py |
RAML | RAML-master/incremental/network/.ipynb_checkpoints/modeling-checkpoint.py | from PIL.Image import NONE
from .utils import IntermediateLayerGetter, DeepLabHeadV3Plus, DeepLabHead, DeepLabHeadV3Plus_Metric
from ._deeplab import DeepLabV3, DeepLabV3_embedding, DeepLabV3_embedding_self_distillation, DeepLabV3_metric
from .backbone import resnet
from .backbone import mobilenetv2
def _segm_resnet(n... | 8,134 | 44.194444 | 194 | py |
RAML | RAML-master/incremental/.ipynb_checkpoints/main-checkpoint.py | from tqdm import tqdm
import network
import utils
import os
import random
import argparse
import numpy as np
import torch.nn.functional as F
from torch.utils import data
from datasets import VOCSegmentation, Cityscapes, cityscapes
from utils import ext_transforms as et
from metrics import StreamSegMetrics
import torc... | 28,621 | 42.170437 | 171 | py |
RAML | RAML-master/incremental/.ipynb_checkpoints/main_metric-checkpoint.py | from tqdm import tqdm
import network
import utils
import os
import random
import argparse
import numpy as np
import torch.nn.functional as F
from torch.utils import data
from datasets import VOCSegmentation, Cityscapes, cityscapes, Cityscapes_Novel
from utils import ext_transforms as et
from metrics import StreamSegMe... | 43,558 | 44.092133 | 152 | py |
RAML | RAML-master/incremental/utils/loss.py | import torch.nn as nn
import torch.nn.functional as F
import torch
import numpy as np
from torch.autograd import Variable
class FocalLoss(nn.Module):
def __init__(self, alpha=1, gamma=0, size_average=True, ignore_index=255):
super(FocalLoss, self).__init__()
self.alpha = alpha
self.gamma = ... | 10,333 | 39.84585 | 177 | py |
RAML | RAML-master/incremental/utils/utils.py | from torchvision.transforms.functional import normalize
import torch.nn as nn
import numpy as np
import os
def denormalize(tensor, mean, std):
mean = np.array(mean)
std = np.array(std)
_mean = -mean/std
_std = 1/std
return normalize(tensor, _mean, _std)
class Denormalize(object):
def __init_... | 2,850 | 28.391753 | 84 | py |
RAML | RAML-master/incremental/utils/scheduler.py | from torch.optim.lr_scheduler import _LRScheduler, StepLR
class PolyLR(_LRScheduler):
def __init__(self, optimizer, max_iters, power=0.9, last_epoch=-1, min_lr=1e-6):
self.power = power
self.max_iters = max_iters # avoid zero lr
self.min_lr = min_lr
super(PolyLR, self).__init__(opt... | 509 | 41.5 | 96 | py |
RAML | RAML-master/incremental/utils/visualizer.py | from visdom import Visdom
import json
class Visualizer(object):
""" Visualizer
"""
def __init__(self, port='13579', env='main', id=None):
self.cur_win = {}
self.vis = Visdom(port=port, env=env)
self.id = id
self.env = env
# Restore
ori_win = self.vis.get_win... | 2,661 | 30.690476 | 86 | py |
RAML | RAML-master/incremental/utils/__init__.py | from .utils import *
# from .visualizer import Visualizer
from .scheduler import PolyLR
from .loss import FocalLoss, CrossEntropyLoss, CrossEntropyLoss_dis, CenterLoss | 167 | 41 | 79 | py |
RAML | RAML-master/incremental/utils/ext_transforms.py | import torchvision
import torch
import torchvision.transforms.functional as F
import random
import numbers
import numpy as np
from PIL import Image
#
# Extended Transforms for Semantic Segmentation
#
class ExtRandomHorizontalFlip(object):
"""Horizontally flip the given PIL Image randomly with a given probabilit... | 20,817 | 35.458844 | 150 | py |
LLP-VAT | LLP-VAT-main/llp_vat/main.py | import argparse
import os
import uuid
from tqdm.auto import tqdm
import arrow
import numpy as np
import torch
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import DataLoader
from torch.utils.data.dataset import random_split
from llp_vat.lib.llp import (BagMiniBatch, load_llp_datase... | 14,895 | 39.150943 | 79 | py |
LLP-VAT | LLP-VAT-main/llp_vat/preprocessing.py | import argparse
from llp_vat.lib.llp import create_llp_dataset
def main(args):
# create LLP dataset
if args.alg == "uniform":
kwargs = dict(replacement=args.replacement,
bag_size=args.bag_size,
seed=args.seed)
elif args.alg == "kmeans":
kwargs =... | 1,501 | 33.136364 | 78 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/losses.py | import contextlib
import torch
import torch.nn as nn
import torch.nn.functional as F
from torch.distributions.constraints import simplex
from llp_vat.lib.networks import GaussianNoise
def compute_soft_kl(inputs, targets):
with torch.no_grad():
loss = cross_entropy_loss(inputs, targets)
loss = to... | 4,292 | 30.8 | 78 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/run_experiment.py | import glob
import os
import pathlib
import warnings
import logzero
import torch
import torch.nn as nn
import yaml
from torch.utils.tensorboard import SummaryWriter
def write_meters(epoch, tag, tb_writer, meters):
for name, value in meters.averages("").items():
tb_writer.add_scalar("{}/{}".format(tag, na... | 3,101 | 31.652632 | 76 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/utils.py | def accuracy(output, target, top_k=(1, )):
"""Computes the precision@k for the specified values of k"""
max_k = max(top_k)
batch_size = target.size(0)
_, pred = output.topk(max_k, 1, True, True)
pred = pred.t()
correct = pred.eq(target.view(1, -1).expand_as(pred))
res = []
for k in top... | 2,897 | 26.084112 | 77 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/networks.py | import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
def wide_resnet28_2(**kwargs):
net = WideResNet(28, 2, **kwargs)
net.apply(conv_init)
return net
class GaussianNoise(nn.Module):
""" add gasussian noise into feature """
def __init__(self, std):
super(G... | 4,260 | 31.526718 | 78 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/llp.py | import os
import pathlib
import time
from itertools import groupby
import numpy as np
import torch
from sklearn.cluster import MiniBatchKMeans
from sklearn.decomposition import PCA
from torch.utils.data import Sampler, BatchSampler, RandomSampler
from llp_vat.lib.datasets import load_dataset
class Iteration:
de... | 5,463 | 31.141176 | 78 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/datasets.py | import torch
import torch.nn.functional as F
from torchvision import transforms
from torchvision.datasets import CIFAR10, CIFAR100, SVHN
class ToOneHot:
def __init__(self, num_classes):
self.num_classes = num_classes
def __call__(self, y: int) -> torch.Tensor:
one_hot = F.one_hot(torch.tensor... | 3,819 | 30.570248 | 75 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/ramps.py | # Copyright (c) 2018, Curious AI Ltd. All rights reserved.
#
# This work is licensed under the Creative Commons Attribution-NonCommercial
# 4.0 International License. To view a copy of this license, visit
# http://creativecommons.org/licenses/by-nc/4.0/ or send a letter to
# Creative Commons, PO Box 1866, Mountain View... | 1,598 | 30.352941 | 76 | py |
LLP-VAT | LLP-VAT-main/llp_vat/lib/__init__.py | 0 | 0 | 0 | py | |
ADLD | ADLD-master/test.py | import argparse
import os
import torch.optim as optim
import torch.utils.data as util_data
import itertools
import network
import pre_process as prep
import lr_schedule
from util import *
from data_list import ImageList_au, ImageList_land_au
optim_dict = {'SGD': optim.SGD, 'Adam': optim.Adam}
def main(config):
... | 5,813 | 43.381679 | 135 | py |
ADLD | ADLD-master/network.py | import torch
import torch.nn as nn
import torch.nn.functional as F
class Feat_Enc(nn.Module):
def __init__(self):
super(Feat_Enc, self).__init__()
self.align_attention_features = nn.Sequential(
nn.Conv2d(3, 32, kernel_size=3, stride=1, padding=1),
nn.BatchNorm2d(32),
... | 8,607 | 32.235521 | 109 | py |
ADLD | ADLD-master/lr_schedule.py | def inv_lr_scheduler(param_lr, optimizer, iter_num, gamma, power, init_lr=0.001):
lr = init_lr * (1 + gamma * iter_num) ** (-power)
i = 0
for param_group in optimizer.param_groups:
param_group['lr'] = lr * param_lr[i]
i += 1
return optimizer
def step_lr_scheduler(param_lr, optimizer,... | 1,092 | 29.361111 | 111 | py |
ADLD | ADLD-master/data_list.py | import numpy as np
import random
from PIL import Image
def make_dataset(image_list, label):
len_ = len(image_list)
images = [(image_list[i].strip(), label[i, :]) for i in range(len_)]
return images
def make_dataset_land_au(image_list, land, au):
len_ = len(image_list)
images = [(image_list[i].st... | 3,195 | 28.321101 | 101 | py |
ADLD | ADLD-master/util.py | import torch
import torch.nn as nn
import torch.nn.functional as F
import numpy as np
import sklearn
from sklearn.metrics import accuracy_score, f1_score
def AU_detection_eval_src(loader, base_net, au_enc, use_gpu=True):
missing_label = 999
for i, batch in enumerate(loader):
input, label = batch
... | 5,630 | 33.335366 | 103 | py |
ADLD | ADLD-master/pre_process.py | import numpy as np
from torchvision import transforms
from PIL import Image
class PlaceCrop(object):
"""Crops the given PIL.Image at the particular index.
Args:
size (sequence or int): Desired output size of the crop. If size is an
int instead of sequence like (w, h), a square crop (size, ... | 3,931 | 32.322034 | 91 | py |
ADLD | ADLD-master/train.py | import argparse
import os
import torch.optim as optim
import torch.utils.data as util_data
import itertools
import network
import pre_process as prep
import lr_schedule
from util import *
from data_list import ImageList_au, ImageList_land_au
optim_dict = {'SGD': optim.SGD, 'Adam': optim.Adam}
def main(config):
... | 26,351 | 58.485327 | 272 | py |
ADLD | ADLD-master/dataset/face_transform.py | import cv2
import numpy as np
import os
import math
def align_face_49pts(img, img_land, box_enlarge, img_size):
leftEye0 = (img_land[2 * 19] + img_land[2 * 20] + img_land[2 * 21] + img_land[2 * 22] + img_land[2 * 23] +
img_land[2 * 24]) / 6.0
leftEye1 = (img_land[2 * 19 + 1] + img_land[2 * 20 ... | 3,367 | 41.1 | 119 | py |
ADLD | ADLD-master/dataset/write_AU_weight.py | import numpy as np
list_path_prefix = '../data/list/'
'''
example of content in 'BP4D_train_AUoccur.txt':
0 0 0 0 1 0
0 0 0 1 1 1
0 0 0 0 0 0
'''
imgs_AUoccur = np.loadtxt(list_path_prefix + 'BP4D_train_AUoccur.txt')
AUoccur_rate = np.zeros((1, imgs_AUoccur.shape[1]))
for i in range(imgs_AUoccur.shape[1]):
AUocc... | 575 | 27.8 | 89 | py |
Fitter | Fitter-master/gsf_core.py | from __future__ import print_function
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
matplotlib_version = eval(matplotlib.__version__.split(".")[0])
if matplotlib_version > 1:
plt.style.use("classic")
plt.rc('font',family='Times New Roman')
import os
import sys
import types
import numpy as ... | 14,048 | 36.364362 | 105 | py |
Fitter | Fitter-master/gsf.py | from __future__ import print_function
import os
import sys
import warnings
from optparse import OptionParser
from gsf_core import *
#Parse the commands#
#-------------------#
parser = OptionParser()
parser.add_option("-w", "--warning", dest="warning",
action="store_true", default=False,
... | 2,177 | 33.03125 | 88 | py |
Fitter | Fitter-master/MockFit.py | import os
import gc
import sys
import gsf
import warnings
import traceback
import importlib
import numpy as np
import rel_SED_Toolkit as sedt
from optparse import OptionParser
from astropy.table import Table
#Include the config directory#
#----------------------------#
if os.path.isdir("configs"):
sys.path.append(... | 4,150 | 38.160377 | 111 | py |
Fitter | Fitter-master/UniFit.py | from __future__ import print_function
import os
from optparse import OptionParser
from astropy.table import Table
def makeCommand(cDict):
"""
Make up the command line from the dict.
"""
commandList = [cDict["head"]]
for item in cDict["options"]:
commandList.append(item)
for item in cDic... | 4,223 | 38.849057 | 100 | py |
Fitter | Fitter-master/mockSED.py | import os
import sys
import types
import importlib
import numpy as np
#np.seterr(all="ignore")
import george
from george import kernels
import matplotlib
import matplotlib.pyplot as plt
matplotlib_version = eval(matplotlib.__version__.split(".")[0])
if matplotlib_version > 1:
plt.style.use("classic")
import sedfit.... | 16,520 | 35.550885 | 116 | py |
Fitter | Fitter-master/gsf_mpi.py | from __future__ import print_function
import os
import sys
import warnings
from optparse import OptionParser
from emcee.utils import MPIPool
from gsf_core import *
#Parse the commands#
#-------------------#
parser = OptionParser()
parser.add_option("-w", "--warning", dest="warning",
action="store_tru... | 2,309 | 31.535211 | 88 | py |
Fitter | Fitter-master/sedfit/sedclass.py | #This code is from: Composite_Model_Fit/dl07/dev_SEDClass.ipynb
import types
import numpy as np
import matplotlib.pyplot as plt
from fitter import basicclass as bc
from . import bandfunc as bf
from .dir_list import filter_path
from scipy.interpolate import splrep, splev
from collections import OrderedDict
import SED_T... | 17,142 | 35.787554 | 122 | py |
Fitter | Fitter-master/sedfit/model_functions.py | import os
import numpy as np
from collections import OrderedDict
import cPickle as pickle
from dir_list import root_path
__all__ = ["funcLib", "discreteFuncList"]
#-> Load the modelDict to select the modules to import
modelDictPath = "{0}temp_model.dict".format(root_path)
if os.path.isfile(modelDictPath):
fp = ope... | 5,200 | 31.304348 | 86 | py |
Fitter | Fitter-master/sedfit/dir_list.py | import os
__all__ = ["root_path", "filter_path", "template_path"]
#-> Obtain the current path
pathList = os.path.abspath(__file__).split("/")
#-> Create the path to the root path
root_path = "/".join(pathList[0:-2]) + "/"
#-> Create the path to the filters
pathList[-1] = "filters/"
filter_path = "/".join(pathList)
#->... | 470 | 26.705882 | 55 | py |
Fitter | Fitter-master/sedfit/sedmodel.py | ## The class of the models for the SED fitting.
import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
from fitter import basicclass as bc
from SED_Toolkit import WaveFromMicron, WaveToMicron
__all__ = ["SedModel"]
ls_mic = 2.99792458e14 # micron/s
class SedModel(bc.ModelCombiner):
... | 10,604 | 41.083333 | 108 | py |
Fitter | Fitter-master/sedfit/bandfunc.py | from __future__ import print_function
import numpy as np
from scipy.interpolate import interp1d, splrep, splev
import cPickle as pickle
ls_mic = 2.99792458e14 #micron/s
def BandAverage(datawave, dataflux, bandwave, bandrsr):
"""
This code calculate the band average of the given spectrum with the given
band... | 16,436 | 33.97234 | 130 | py |
Fitter | Fitter-master/sedfit/__init__.py | 0 | 0 | 0 | py | |
Fitter | Fitter-master/sedfit/fit_functions.py | import numpy as np
from scipy.special import erf
import george
from george import kernels
sqrt2 = np.sqrt(2)
PI2 = 2. * np.pi
#-->There are three ways to define the chi-square function to consider the
#upperlimits. The ChiSq functions are defined as (-2)*lnLikelihood.
#->The ChiSq_erf is preferred since it smoothly ch... | 9,058 | 28.412338 | 96 | py |
Fitter | Fitter-master/sedfit/SED_Toolkit.py |
# coding: utf-8
# # This page is to release the functions to manipulate the SEDs and spectra
# * The prototype of this page is [SEDToolKit](http://localhost:8888/notebooks/SEDFitting/SEDToolKit.ipynb) in /Users/jinyi/Work/PG_QSO/SEDFitting/
# In[2]:
import numpy as np
import matplotlib.gridspec as gridspec
import m... | 19,951 | 29.507645 | 147 | py |
Fitter | Fitter-master/sedfit/mcmc/mcmc_multinest.py | import os
from sys import platform
import numpy as np
import pymultinest
import threading, subprocess
from .. import fit_functions as sedff
#The log_likelihood function
lnlike = sedff.logLFunc
#The log_likelihood function using Gaussian process regression
lnlike_gp = sedff.logLFunc_gp
#->Auxillary functions
def show... | 3,998 | 35.027027 | 88 | py |
Fitter | Fitter-master/sedfit/mcmc/mcmc_emcee.py | import acor
import emcee
import corner
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MaxNLocator
from scipy.stats import truncnorm
from time import time
from ..SED_Toolkit import WaveFromMicron, WaveToMicron
from .. import fit_functions as sedff
#from .. import fit_functions_erf as se... | 27,070 | 39.224368 | 116 | py |
Fitter | Fitter-master/sedfit/mcmc/__init__.py | 1 | 0 | 0 | py | |
Fitter | Fitter-master/sedfit/mcmc/mcmc_dnest4.py | #This script is not ready...
#
import os
from sys import platform
import numpy as np
import pymultinest
import threading, subprocess
from .. import fit_functions as sedff
#The log_likelihood function
lnlike = sedff.logLFunc
#The log_likelihood function using Gaussian process regression
lnlike_gp = sedff.logLFunc_gp
... | 6,241 | 36.60241 | 102 | py |
Fitter | Fitter-master/sedfit/models/model_torus_template.py | import numpy as np
from astropy.table import Table
if __name__ == "__main__":
from sedfit.dir_list import template_path
else:
from ..dir_list import template_path
from scipy.interpolate import interp1d
Mpc = 3.08567758e24 #unit: cm
mJy = 1e26 #unit: erg/s/cm^2/Hz
pi = np.pi
torus_total_tb = Table.read(templ... | 2,547 | 30.45679 | 89 | py |
Fitter | Fitter-master/sedfit/models/model_extinction.py | import numpy as np
from extinction import calzetti00
waveLim = [0.12, 2.2] # units: Micron
def Calzetti00(Av, wave, Rv=3.1, waveLim=waveLim, QuietMode=True):
"""
Calculate the extinction that is directly applied to the flux:
10**(-0.4 * A_lambda).
For the input wavelength out of the effective range... | 2,148 | 31.074627 | 89 | py |
Fitter | Fitter-master/sedfit/models/model_mir_extinction.py | # Add extinction function
import numpy as np
from scipy import interpolate
from ..dir_list import template_path
f = np.loadtxt(template_path+'tau_lambda_kemper_new.txt')
xaxis = f[:, 0]
yaxis = f[:, 1]
k = interpolate.interp1d(xaxis,yaxis,kind='cubic')
def Smith07(logtau, wave):
"""
This function adopts the e... | 883 | 27.516129 | 79 | py |
Fitter | Fitter-master/sedfit/models/model_dl07.py | import numpy as np
import cPickle as pickle
from ..fitter.template import Template
from scipy.interpolate import splev
from ..dir_list import template_path
Msun = 1.9891e33 #unit: gram
Mpc = 3.08567758e24 #unit: cm
m_H = 1.6726219e-24 #unit: gram
fp = open(template_path+"dl07_kdt_mw.tmplt")
tp_dl07 = pickle.load(fp)
... | 3,906 | 29.286822 | 103 | py |
Fitter | Fitter-master/sedfit/models/model_cat3d_H.py | import numpy as np
import cPickle as pickle
from ..fitter.template import Template
from scipy.interpolate import splev
from ..dir_list import template_path
Msun = 1.9891e33 #unit: gram
Mpc = 3.08567758e24 #unit: cm
m_H = 1.6726219e-24 #unit: gram
r0 = 1.1 # pc
fp = open(template_path+"Cat3d_H.tmplt")
tp_cat3d_H = pi... | 3,104 | 25.538462 | 97 | py |
Fitter | Fitter-master/sedfit/models/Radiation_Model_Toolkit.py |
# coding: utf-8
# # This page is to release the functions of radiation models
# * The prototype of this page is [SEDToolKit](http://localhost:8888/notebooks/SEDFitting/SEDToolKit.ipynb) in /Users/jinyi/Work/PG_QSO/SEDFitting/
# In[2]:
import numpy as np
# In[1]:
#Func_bgn:
#----------------------------------#
# ... | 5,691 | 27.893401 | 147 | py |
Fitter | Fitter-master/sedfit/models/model_xl.py | import numpy as np
import cPickle as pickle
import Radiation_Model_Toolkit as rmt
from ..fitter.template import Template
from ..dir_list import template_path
ls_mic = 2.99792458e14 #unit: micron/s
Mpc = 3.08567758e24 #unit: cm
Msun = 1.9891e33 #unit: gram
def Dust_Emission(T, Md, kappa, wave, DL, z, frame="rest"):
... | 8,046 | 30.806324 | 82 | py |
Fitter | Fitter-master/sedfit/models/model_bc03_refine.py | import numpy as np
import cPickle as pickle
from ..fitter.template import Template
from ..dir_list import template_path
Msun = 1.9891e33 #unit: gram
Mpc = 3.08567758e24 #unit: cm
mJy = 1e26 #unit: erg/s/cm^2/Hz
pi = np.pi
fp = open(template_path+"bc03_sps_cha_kdt.tmplt")
tp_bc03 = pickle.load(fp)
fp.close()
bc03 = T... | 2,918 | 28.19 | 85 | py |
Fitter | Fitter-master/sedfit/models/ndiminterpolation.py | __author__ = "Robert Nikutta <robert.nikutta@gmail.com>"
__version__ = '20150416'
import numpy as N
import warnings
from scipy import interpolate, ndimage
# Convert RuntimeWarnings, e.g. division by zero in some array elements, to Exceptions
warnings.simplefilter('error', RuntimeWarning)
class NdimInterpolation:
... | 6,426 | 34.313187 | 116 | py |
Fitter | Fitter-master/sedfit/models/model_analyticals.py | import numpy as np
import Radiation_Model_Toolkit as rmt
__all__ = ["BlackBody", "Modified_BlackBody", "Power_Law", "Synchrotron",
"Linear", "Line_Gaussian_L", "Poly3"]
ls_mic = 2.99792458e14 #unit: micron/s
Mpc = 3.08567758e24 #unit: cm
mJy = 1e-26 #1 mJy in erg/s/cm^2/Hz
def BlackBody(logOmega, T, wave)... | 5,625 | 25.28972 | 91 | py |
Fitter | Fitter-master/sedfit/models/model_bc03.py | import numpy as np
import cPickle as pickle
from ..fitter.template import Template
from ..dir_list import template_path
Msun = 1.9891e33 #unit: gram
Mpc = 3.08567758e24 #unit: cm
mJy = 1e26 #unit: erg/s/cm^2/Hz
pi = np.pi
fp = open(template_path+"bc03_kdt.tmplt")
tp_bc03 = pickle.load(fp)
fp.close()
bc03 = Template(... | 7,374 | 35.509901 | 118 | py |
Fitter | Fitter-master/sedfit/models/model_clumpy.py | import h5py
import numpy as np
import cPickle as pickle
import ndiminterpolation as ndip
from ..fitter.template import Template
from ..dir_list import template_path
pi = np.pi
Mpc = 3.08567758e24 #unit: cm
#Func_bgn:
#-------------------------------------#
# Created by SGJY, May. 3, 2016 #
#--------------------... | 4,132 | 29.843284 | 96 | py |
Fitter | Fitter-master/sedfit/models/__init__.py | 0 | 0 | 0 | py | |
Fitter | Fitter-master/sedfit/models/model_cat3d_G.py | import numpy as np
import cPickle as pickle
from ..fitter.template import Template
from scipy.interpolate import splev
from ..dir_list import template_path
Msun = 1.9891e33 #unit: gram
Mpc = 3.08567758e24 #unit: cm
m_H = 1.6726219e-24 #unit: gram
r0 = 1.1 # pc
fp = open(template_path+"Cat3d_G.tmplt")
tp_cat3d_G = pi... | 2,993 | 25.034783 | 97 | py |
Fitter | Fitter-master/sedfit/models/model_cat3d_H_wind.py | import numpy as np
import cPickle as pickle
from ..fitter.template import Template
from scipy.interpolate import splev
from ..dir_list import template_path
Msun = 1.9891e33 #unit: gram
Mpc = 3.08567758e24 #unit: cm
m_H = 1.6726219e-24 #unit: gram
r0 = 1.1 # pc
fp = open(template_path+"Cat3d_H_wind.tmplt")
tp_cat3d_H... | 3,316 | 26.641667 | 124 | py |
Fitter | Fitter-master/sedfit/models/model_pah.py | import numpy as np
from scipy.interpolate import interp1d
from ..dir_list import template_path
Mpc = 3.08567758e24 #unit: cm
pi = np.pi
tb = np.genfromtxt(template_path+"PAH.template_HLC.dat")
twave = tb[:, 0]
tflux_temp = tb[:, 1]
norm = np.trapz(tflux_temp, twave)
tflux = tflux_temp / norm
tPAH = interp1d(twave, tf... | 1,971 | 26.774648 | 89 | py |
Fitter | Fitter-master/sedfit/fitter/basicclass.py | #The code comes from Composite_Model_Fit/dl07/dev_DataClass.ipynb
import types
import numpy as np
from collections import OrderedDict
import matplotlib.pyplot as plt
from .. import model_functions as sedmf
#Data class#
#----------#
#The basic class of data unit
class DataUnit(object):
def __init__(self, x, y, e... | 31,802 | 32.266736 | 104 | py |
Fitter | Fitter-master/sedfit/fitter/template.py | import numpy as np
from sklearn.neighbors import KDTree
from sklearn.decomposition import PCA
from scipy.interpolate import splev
class Template(object):
"""
This is the object of a model template.
"""
def __init__(self, tckList, kdTree, parList, modelInfo={}, parFormat=[], readMe=""):
self.__... | 3,426 | 25.565891 | 92 | py |
Fitter | Fitter-master/sedfit/fitter/__init__.py | 0 | 0 | 0 | py | |
Fitter | Fitter-master/examples/config_example_pht.py | ################################################################################
## This is config is an example of photometric SED fitting.
## The data used is IRSA13120-5453 a luminous infrared galaxy.
## The adopted models are:
## BC03 -- Stellar emisison
## Smith07 -- MIR extinction
## Cat3d_H -- Dust toru... | 10,477 | 41.942623 | 80 | py |
Fitter | Fitter-master/examples/config_example_spc.py | ################################################################################
## This is config is an example of full SED fitting.
## The data used is IRSA13120-5453 a luminous infrared galaxy.
## The adopted models are:
## BC03 -- Stellar emisison
## Smith07 -- MIR extinction (two components applie... | 8,441 | 32.5 | 86 | py |
Fitter | Fitter-master/gauss/dnest_discrete.py | import numpy as np
import dnest4
from dnest4.utils import rng
import fitter.basicclass as bc
from gaussian_model import MultiGaussian, GaussianModelDiscrete
import matplotlib.pyplot as plt
import cPickle as pickle
import types
def logLFunc_simple(params, data, model):
parDict = model.get_modelParDict()
pIndex ... | 3,245 | 30.211538 | 83 | py |
Fitter | Fitter-master/gauss/dnest_continual.py | import os
import numpy as np
import dnest4
from dnest4.utils import rng
import fitter.basicclass as bc
from gaussian_model import MultiGaussian, GaussianModelSet, GaussFunc
import matplotlib.pyplot as plt
import cPickle as pickle
import types
#DNest4 model#
#------------#
class DNest4Model(object):
"""
Specif... | 6,165 | 34.034091 | 98 | py |
Fitter | Fitter-master/gauss/mock_data_gauss.py | import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
from gaussian_model import MultiGaussian, GaussianModelDiscrete
#Generate the mock data#
#-----------------#
Ndata = 50
xMax = 800.0
Nmodel = 10
fAdd = None #0.1
pRange = [
[5.0, 20.0], #The range of a
[20.0, 580.0], #The range ... | 1,263 | 24.795918 | 63 | py |
Fitter | Fitter-master/gauss/plot_result_discrete.py | import numpy as np
import matplotlib.pyplot as plt
from gaussian_model import GaussFunc
import cPickle as pickle
fp = open("test_model.dict", "r")
model = pickle.load(fp)
fp.close()
ps = np.loadtxt("posterior_sample.txt")
xd = model['x']
yTrue = model['y_true']
yObsr = model['y_obsr']
yErr = model['y_err']
pValue = m... | 2,434 | 29.4375 | 80 | py |
Fitter | Fitter-master/gauss/gaussian_model.py | import numpy as np
import matplotlib.pyplot as plt
from collections import OrderedDict
from scipy.interpolate import interp1d
import fitter.basicclass as bc
def GaussFunc(a, b, c, x):
return a * np.exp( -0.5 * ( (x - b) / c )**2. )
def MultiGaussian(x, p_range, n_model, f_add=None, QuietMode=True):
"""
Ge... | 7,247 | 31.213333 | 78 | py |
Fitter | Fitter-master/gauss/plot_result_continual.py | import sys
import numpy as np
import matplotlib.pyplot as plt
from gaussian_model import GaussFunc
import cPickle as pickle
dataName = sys.argv[1]
fp = open("{0}.dict".format(dataName), "r")
model = pickle.load(fp)
fp.close()
ps = np.loadtxt("{0}_c_posterior.txt".format(dataName))
xd = model['x']
yTrue = model['y_tru... | 2,219 | 29 | 80 | py |
Fitter | Fitter-master/template/bc03_grid.py | import ezgal
import numpy as np
from sedfit.fitter.template import Template
from sklearn.neighbors import KDTree
from scipy.interpolate import splrep, splev
import matplotlib.pyplot as plt
import cPickle as pickle
ls_mic = 2.99792458e14 #micron/s
ls_aa = 2.99792458e18 #aa/s
Mpc = 3.08567758e24 #cm
Lsun = 3.828e33... | 6,572 | 40.339623 | 118 | py |
Fitter | Fitter-master/template/tb_dl07.py | import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
#from sedfit.fitter.template import Template
from sklearn.neighbors import KDTree
from scipy.interpolate import splrep, splev
#'''
class Template(object):
"""
This is the object of a model template.
"""
def __init__(self, tckL... | 4,747 | 29.632258 | 89 | py |
Fitter | Fitter-master/template/tb_clumpy.py | import h5py
import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
from sedfit.fitter.template import Template
from sklearn.neighbors import KDTree
from scipy.interpolate import splrep, splev
from collections import Counter
ls_mic = 2.99792458e14 #micron/s
f_test = 1
f_compile = 0
qList = [0., ... | 4,532 | 32.087591 | 88 | py |
Fitter | Fitter-master/template/tb_dust_xl.py | #This code generate the KDTree template file that can be directly used.
import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
from sklearn.neighbors import KDTree
from scipy.interpolate import splrep, splev
from sedfit.fitter.template import Template
modelDir = "/Users/jinyi/Work/mcmc/Fitter/tem... | 5,187 | 29.339181 | 96 | py |
Fitter | Fitter-master/template/tb_dl07_MW.py | # This script is to generate the DL07 model template. The model templates only
# include the Milky Way models, because the SMG and LMG templates are not
# consistent change when the qPAH parameter change.
#
import numpy as np
import matplotlib.pyplot as plt
import cPickle as pickle
from sedfit.fitter.template import T... | 3,652 | 31.90991 | 95 | py |
Fitter | Fitter-master/template/tb_cat3d_H_wind.py | import numpy as np
import cPickle as pickle
import matplotlib.pyplot as plt
from sedfit.fitter.template import Template
from scipy.interpolate import splrep, splev
from sklearn.neighbors import KDTree
from astropy.table import Table
from glob import glob
N0List = [5, 7.5, 10]
awList = [-0.50, -1.00, -1.50, -2.00, -2.5... | 4,283 | 24.2 | 77 | py |
Fitter | Fitter-master/template/bc03_sps_cha.py | import numpy as np
from sedfit.fitter.template import Template
from sklearn.neighbors import KDTree
from scipy.interpolate import splrep, splev
import matplotlib.pyplot as plt
import cPickle as pickle
from sgPhot import extractSED
ls_mic = 2.99792458e14 #micron/s
ls_aa = 2.99792458e18 #aa/s
Mpc = 3.08567758e24 #cm
... | 2,988 | 30.463158 | 85 | py |
Fitter | Fitter-master/template/tb_cat3d_H.py | import numpy as np
import cPickle as pickle
import matplotlib.pyplot as plt
from sedfit.fitter.template import Template
from scipy.interpolate import splrep, splev
from sklearn.neighbors import KDTree
from astropy.table import Table
from glob import glob
aList = [-0.25, -0.50, -0.75, -1.00, -1.25, -1.50, -1.75, -2.00,... | 2,765 | 22.05 | 78 | py |
Fitter | Fitter-master/template/clumpy_pca.py | #This script use the PCA method to decompose the CLUMPY templates. It is found
#that the normalised templates are not very well recovered. Therefore, we
#decompose the original ones from "clumpy_models_201410_tvavg.hdf5".
#The aim of this decomposition is to reduce the data file size while keeping the
#accuracy of the ... | 4,611 | 33.162963 | 92 | py |
Fitter | Fitter-master/postprocess/extraction.py | #!/Users/jinyi/anaconda/bin/python
from __future__ import print_function
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
matplotlib_version = eval(matplotlib.__version__.split(".")[0])
if matplotlib_version > 1:
plt.style.use("classic")
plt.rc('font',family='Times New Roman')
import sys
imp... | 4,532 | 33.340909 | 151 | py |
Fitter | Fitter-master/postprocess/__init__.py | 0 | 0 | 0 | py | |
Fitter | Fitter-master/postprocess/PostProcessTools.py | #This script provide some functions to do the postprocess of the fitting sampling.
#
import os
import numpy as np
import cPickle as pickle
from sedfit.dir_list import root_path
from scipy.interpolate import interp1d
ls_mic = 2.99792458e14 #unit: micron/s
Mpc = 3.08567758e24 #unit: cm
mJy = 1e26 #unit: erg/s/cm^2/Hz
_... | 12,092 | 27.656398 | 88 | py |
Fitter | Fitter-master/postprocess/postprocess.py | #!/Users/jinyi/anaconda/bin/python
from __future__ import print_function
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt
matplotlib_version = eval(matplotlib.__version__.split(".")[0])
if matplotlib_version > 1:
plt.style.use("classic")
plt.rc('font',family='Times New Roman')
import sys
imp... | 5,339 | 29.689655 | 98 | py |
Fitter | Fitter-master/configs/config_example_rl.py | #This config file is for the radio loud sources.
#
import numpy as np
from collections import OrderedDict
################################################################################
# Data #
###################################################... | 7,226 | 32.151376 | 80 | py |
Fitter | Fitter-master/configs/config_example_dl07.py | #This config file is for the radio quiet sources.
#
import numpy as np
from collections import OrderedDict
################################################################################
# Data #
##################################################... | 4,014 | 30.614173 | 80 | py |
Fitter | Fitter-master/configs/config_example_rq.py | #This config file is for the radio quiet sources.
#
import numpy as np
from collections import OrderedDict
################################################################################
# Data #
##################################################... | 6,773 | 32.87 | 155 | py |
MICO | MICO-main/setup.py | from setuptools import setup
if __name__ == "__main__":
setup()
| 69 | 13 | 28 | py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.