index
int64
repo_name
string
branch_name
string
path
string
content
string
import_graph
string
13,351
sajetan/contact_book
refs/heads/master
/project/tables.py
from project import * from passlib.apps import custom_app_context as pwd_context from itsdangerous import (TimedJSONWebSignatureSerializer as Serializer, BadSignature, SignatureExpired) #app.config['SECRET_KEY'] = 'the quick brown fox jumps over the lazy dog' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///contacts_database.db' db = SQLAlchemy(app) ''' class User(db.Model): __tablename__ = "user_info" id = db.Column(db.Integer, primary_key=True) username = db.Column(db.String(128), index=True, nullable=False,unique=True) password = db.Column(db.String(128),nullable=False) def hash_password(self, password): self.password = pwd_context.encrypt(password) def verify_password(self, password): return pwd_context.verify(password, self.password) def generate_auth_token(self, expiration=400000): s = Serializer(db.app.config['SECRET_KEY'], expires_in=expiration) return s.dumps({'id': self.id}) @staticmethod def verify_auth_token(token): s = Serializer('the quick brown fox jumps over the lazy dog') try: data = s.loads(token) except SignatureExpired: return None # valid token, but expired except BadSignature: return None # invalid token user = User.query.filter_by(id = data['id']).first() return user ''' class Contact(db.Model): __tablename__ = 'contacts' id = db.Column(db.Integer, primary_key=True) name = db.Column(db.String(80), nullable=False) surname = db.Column(db.String(100), nullable=True) email = db.Column(db.String(200), nullable=True, unique=True) phone = db.Column(db.String(20), nullable=True) db.create_all()
{"/project/Authentication.py": ["/project/__init__.py"], "/project/tables.py": ["/project/__init__.py"], "/project/contacts.py": ["/project/__init__.py", "/project/tables.py"], "/app.py": ["/project/__init__.py", "/project/authentication.py"], "/project/authentication.py": ["/project/__init__.py"]}
13,352
sajetan/contact_book
refs/heads/master
/project/contacts.py
from project import * from project.tables import db,Contact from Authentication import UserAuth #from test import * from validate_form import * from validate_email import validate_email class ContactsAppShow(Resource): def get(self,id=None): ''' Shows all the contacts in alphabetical order by name. Shows 10 contacts per page. ''' if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) contact_data=[] app.logger.info('GET contacts data query') try: contact_data = Contact.query.order_by(Contact.name).paginate(per_page=10, page=id, error_out=True) except: contact_data = Contact.query.order_by(Contact.name).paginate(per_page=10, page=1, error_out=True) headers = {'Content-Type': 'text/html'} return make_response(render_template('app.html',contact_data=contact_data), 200, headers) class ContactsAppSearch(Resource): def get(self): headers = {'Content-Type': 'text/html'} return make_response(render_template('search.html'), 200, headers) def post(self): ''' Search any contact by name or email address ''' if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) contact_data=None if 'name' in request.form.keys(): if (request.form['name']): app.logger.info('Search for name [ %s ]',request.form['name']) contact_data = Contact.query.filter_by(name=request.form['name']) if 'email' in request.form.keys(): if (request.form['email']): if (validate_email(request.form['email'])): app.logger.info('Search for email [ %s ]',request.form['email']) contact_data = Contact.query.filter_by(email=request.form['email']) else: flash("Enter valid Email Address") headers = {'Content-Type': 'text/html'} return make_response(render_template('search.html',contact_data=contact_data), 200, headers) class ContactsAppDelete(Resource): def post(self): ''' Delete the contact ''' if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) try: contact_data = Contact.query.filter_by(id=request.form['id']).first() app.logger.info('Deleting contact [ %s ]',contact_data.name) db.session.delete(contact_data) db.session.commit() message="Deleted " +contact_data.name + "'s Contact" flash(message) except: db.session.rollback() flash('Error deleting contact.') app.logger.info('Error deleting contact ') return redirect(url_for('contacts',page=request.form['page'])) class ContactsAppEdit(Resource): def get(self,id): if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) contact_data= Contact.query.filter_by(id=id).first() form = ContactForm(obj=contact_data) headers = {'Content-Type': 'text/html'} return make_response(render_template('edit.html', form=form), 200, headers) def post(self,id): ''' Edit by name/surname/email/phonenumber Email id is unique for the user, so throws error if email already exists in the database ''' if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) pageid = request.args.to_dict() contact_data = Contact.query.filter_by(id=id).first() form = ContactForm(obj=contact_data) if form.validate_on_submit(): try: #update to database form.populate_obj(contact_data) db.session.add(contact_data) db.session.commit() message = "Changed " + contact_data.name + "'s Contact Details" app.logger.info('Edited contact [ %s ] success', contact_data.name) flash(message, 'success') return redirect(url_for('contacts',page=pageid["page"])) except: db.session.rollback() flash('Error updating contact. Email already exist or User not found') headers = {'Content-Type': 'text/html'} return make_response(render_template('edit.html', form=form), 200, headers) class ContactsAppAdd(Resource): def get(self): if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) form = ContactForm() headers = {'Content-Type': 'text/html'} return make_response(render_template('add.html',form=form), 200, headers) def post(self): ''' Add new contact with name/surname/email/phonenumber Email id is unique for the user, so throws error if email already exists in the database ''' if not session.get('logged_in'): flash("Please Log in") return redirect(url_for('index')) form = ContactForm() if form.validate_on_submit(): contact_data = Contact() form.populate_obj(contact_data) db.session.add(contact_data) try: # update to database db.session.commit() flash('Contact created Success') app.logger.info('Added a new user successfully') return redirect(url_for('contacts')) except: db.session.rollback() flash('Error Creating this contact - Email already in use') headers = {'Content-Type': 'text/html'} return make_response(render_template('add.html', form=form), 200, headers) api.add_resource(ContactsAppShow,'/contacts','/contacts/<int:id>',endpoint="contacts") api.add_resource(ContactsAppDelete,'/contacts/delete',endpoint="contacts_delete") api.add_resource(ContactsAppEdit,'/edit_contact/<int:id>',endpoint="edit_contact") api.add_resource(ContactsAppAdd,'/contact_add',endpoint="contact_add") api.add_resource(ContactsAppSearch,'/contact_search',endpoint="contact_search")
{"/project/Authentication.py": ["/project/__init__.py"], "/project/tables.py": ["/project/__init__.py"], "/project/contacts.py": ["/project/__init__.py", "/project/tables.py"], "/app.py": ["/project/__init__.py", "/project/authentication.py"], "/project/authentication.py": ["/project/__init__.py"]}
13,353
sajetan/contact_book
refs/heads/master
/app.py
from project import * from project.authentication import * @app.route('/') def index(): if not session.get('logged_in'): return render_template('login.html') else: return redirect(url_for('contacts')) if __name__ == '__main__': app.run(host='0.0.0.0',debug=True,threaded=True)
{"/project/Authentication.py": ["/project/__init__.py"], "/project/tables.py": ["/project/__init__.py"], "/project/contacts.py": ["/project/__init__.py", "/project/tables.py"], "/app.py": ["/project/__init__.py", "/project/authentication.py"], "/project/authentication.py": ["/project/__init__.py"]}
13,354
sajetan/contact_book
refs/heads/master
/project/authentication.py
#vim: tabstop=4 expandtab shiftwidth=4 softtabstop=4 from project import * #from project.tables import db,User from Authentication import UserAuth from contacts import * class UserAuthentication(Resource): def get(self): headers = {'Content-Type': 'text/html'} return make_response(render_template('login.html'), 200, headers) def post(self): userObj = UserAuth(request.form['username'],request.form['password']) res = userObj.do_authentication() if res: flash("Login Success") app.logger.info('Login successful') return redirect(url_for('contacts')) else: flash("Password entered is Invalid") app.logger.info('Invalid Password') return redirect(url_for('index')) class UserLogout(Resource): def get(self): session['logged_in'] = False app.logger.info('Logout successful') return redirect(url_for('index')) ''' #test @auth.error_handler def unauthorized(): return make_response(jsonify( { 'error': 'Unauthorized access!!!' } ), 403) @auth.verify_password def verify_password(username_or_token, password): # first try to authenticate by token print('Authenticating..') user = User.verify_auth_token(username_or_token) #return True if not user: # try to authenticate with username/password user = User.query.filter_by(username = username_or_token).first() g.user = user print('Authentication successful') return True @app.route('/api/token') @auth.login_required def get_auth_token(): token = g.user.generate_auth_token(600) return jsonify({'token': token.decode('ascii'), 'duration': 600}) ''' api.add_resource(UserAuthentication, '/login',endpoint="login") api.add_resource(UserLogout, '/logout',endpoint="logout")
{"/project/Authentication.py": ["/project/__init__.py"], "/project/tables.py": ["/project/__init__.py"], "/project/contacts.py": ["/project/__init__.py", "/project/tables.py"], "/app.py": ["/project/__init__.py", "/project/authentication.py"], "/project/authentication.py": ["/project/__init__.py"]}
13,377
guilhermeulbriki/Django-CadastroClientes
refs/heads/master
/clientes/migrations/0002_funcionario.py
# Generated by Django 2.2.7 on 2019-11-25 14:18 from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('clientes', '0001_initial'), ] operations = [ migrations.CreateModel( name='Funcionario', fields=[ ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('nome', models.CharField(max_length=255, verbose_name='Nome')), ('apelido', models.CharField(max_length=255, verbose_name='Apelido')), ('snap', models.CharField(max_length=255, verbose_name='Snap')), ('cpf', models.CharField(max_length=255, verbose_name='CPF')), ], ), ]
{"/clientes/forms.py": ["/clientes/models.py"], "/clientes/admin.py": ["/clientes/models.py"], "/clientes/views.py": ["/clientes/models.py", "/clientes/forms.py"]}
13,378
guilhermeulbriki/Django-CadastroClientes
refs/heads/master
/clientes/forms.py
from django import forms from .models import Cliente, Funcionario class ClienteForm(forms.ModelForm): class Meta: model = Cliente fields = ('nome', 'endereco', 'telefone', 'cpf') class FuncionarioForm(forms.ModelForm): class Meta: model = Funcionario fields = ('nome', 'apelido', 'snap', 'cpf')
{"/clientes/forms.py": ["/clientes/models.py"], "/clientes/admin.py": ["/clientes/models.py"], "/clientes/views.py": ["/clientes/models.py", "/clientes/forms.py"]}
13,379
guilhermeulbriki/Django-CadastroClientes
refs/heads/master
/clientes/admin.py
from django.contrib import admin from.models import Cliente admin.site.register(Cliente)
{"/clientes/forms.py": ["/clientes/models.py"], "/clientes/admin.py": ["/clientes/models.py"], "/clientes/views.py": ["/clientes/models.py", "/clientes/forms.py"]}
13,380
guilhermeulbriki/Django-CadastroClientes
refs/heads/master
/clientes/views.py
from datetime import datetime from django.shortcuts import render, redirect from django.http import HttpResponse from .models import Cliente, Funcionario from .forms import ClienteForm, FuncionarioForm from django.views.generic.edit import CreateView, UpdateView from django.urls import reverse_lazy def home(request): clientes = Cliente.objects.all() funcionarios = Funcionario.objects.all() contexto = { 'clientes': clientes, 'funcionarios': funcionarios, } resposta = render(request, template_name="clientes/home.html", context=contexto) return HttpResponse(resposta) class ClienteCreateView(CreateView): model = Cliente form_class = ClienteForm template_name = "clientes/cliente_form.html" success_url = reverse_lazy('home') class ClienteUpdateView(UpdateView): model = Cliente form_class = ClienteForm template_name = "clientes/cliente_form.html" success_url = reverse_lazy('home') def detalhes_cliente(request, pk): cliente = Cliente.objects.get(pk=pk) contexto = { 'cliente': cliente, } resposta = render(request, template_name="clientes/cliente.html", context=contexto) return HttpResponse(resposta) def deleta_cliente(request, pk): cliente = Cliente.objects.get(pk=pk) cliente.delete() return redirect('home') class FuncionarioCreateView(CreateView): model = Funcionario form_class = FuncionarioForm template_name = "funcionarios/funcionario_form.html" success_url = reverse_lazy('home') class FuncionarioUpdateView(UpdateView): model = Funcionario form_class = FuncionarioForm template_name = "funcionarios/funcionario_form.html" success_url = reverse_lazy('home') def detalhes_funcionario(request, pk): funcionario = Funcionario.objects.get(pk=pk) contexto = { 'funcionario': funcionario, } resposta = render(request, template_name="funcionarios/funcionario.html", context=contexto) return HttpResponse(resposta) def deleta_funcionario(request, pk): funcionario = Funcionario.objects.get(pk=pk) funcionario.delete() return redirect('home')
{"/clientes/forms.py": ["/clientes/models.py"], "/clientes/admin.py": ["/clientes/models.py"], "/clientes/views.py": ["/clientes/models.py", "/clientes/forms.py"]}
13,381
guilhermeulbriki/Django-CadastroClientes
refs/heads/master
/aulatopicos/urls.py
from django.contrib import admin from django.urls import path from clientes import views as cliente_views urlpatterns = [ path('', cliente_views.home, name='home'), path('cliente/add/', cliente_views.ClienteCreateView.as_view(), name="add_cliente"), path('funcionario/add/', cliente_views.FuncionarioCreateView.as_view(), name="add_funcionario"), path('cliente/<int:pk>/', cliente_views.detalhes_cliente, name="detalhes_cliente"), path('funcionario/<int:pk>/', cliente_views.detalhes_funcionario, name="detalhes_funcionario"), path('cliente/<int:pk>/update/', cliente_views.ClienteUpdateView.as_view(), name="update_cliente"), path('cliente/<int:pk>/deleta/', cliente_views.deleta_cliente, name="deleta_cliente"), path('funcionario/<int:pk>/update/', cliente_views.FuncionarioUpdateView.as_view(), name="update_funcionario"), path('funcionario/<int:pk>/deleta/', cliente_views.deleta_funcionario, name="deleta_funcionario"), path('admin/', admin.site.urls), ]
{"/clientes/forms.py": ["/clientes/models.py"], "/clientes/admin.py": ["/clientes/models.py"], "/clientes/views.py": ["/clientes/models.py", "/clientes/forms.py"]}
13,382
guilhermeulbriki/Django-CadastroClientes
refs/heads/master
/clientes/models.py
from django.db import models class Cliente(models.Model): nome = models.CharField(max_length=255, verbose_name="Nome") endereco = models.CharField(max_length=350, verbose_name="Endereço") telefone = models.CharField(max_length=255, verbose_name="Telefone") cpf = models.CharField(max_length=255, verbose_name="CPF") class Funcionario(models.Model): nome = models.CharField(max_length=255, verbose_name="Nome") apelido = models.CharField(max_length=255, verbose_name="Apelido") snap = models.CharField(max_length=255, verbose_name="Snap") cpf = models.CharField(max_length=255, verbose_name="CPF")
{"/clientes/forms.py": ["/clientes/models.py"], "/clientes/admin.py": ["/clientes/models.py"], "/clientes/views.py": ["/clientes/models.py", "/clientes/forms.py"]}
13,384
cnry/icevision
refs/heads/master
/tests/data/test_data_splitter.py
import pytest from icevision.all import * @pytest.fixture def records(): def create_record_func(): return BaseRecord([]) records = RecordCollection(create_record_func) for record_id in ["file1", "file2", "file3", "file4"]: records.get_by_record_id(record_id) return records def test_single_split_splitter(records): data_splitter = SingleSplitSplitter() splits = data_splitter(records) assert splits == [["file1", "file2", "file3", "file4"]] def test_random_splitter(records): data_splitter = RandomSplitter([0.6, 0.2, 0.2], seed=42) splits = data_splitter(records) np.testing.assert_equal(splits, [["file2", "file4"], ["file1"], ["file3"]]) def test_fixed_splitter(records): presplits = [["file4", "file3"], ["file2"], ["file1"]] data_splitter = FixedSplitter(presplits) splits = data_splitter(records) assert splits == presplits
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,385
cnry/icevision
refs/heads/master
/icevision/models/mmdet/models/vfnet/backbones/__init__.py
from icevision.models.mmdet.models.vfnet.backbones.resnet_fpn import *
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,386
cnry/icevision
refs/heads/master
/icevision/models/fastai/unet/lightning/__init__.py
from icevision.models.fastai.unet.lightning.model_adapter import *
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,387
cnry/icevision
refs/heads/master
/icevision/models/fastai/unet/fastai/__init__.py
from icevision.models.fastai.unet.fastai.callbacks import * from icevision.models.fastai.unet.fastai.learner import *
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,388
cnry/icevision
refs/heads/master
/tests/models/torchvision_models/keypoints_rcnn/test_backbones.py
import pytest from icevision.all import * from icevision.models.torchvision import keypoint_rcnn @pytest.mark.parametrize( "model_name,param_groups_len", ( ("mobilenet", 6), ("resnet18", 7), ("resnet18_fpn", 8), ("resnext50_32x4d_fpn", 8), ("wide_resnet50_2_fpn", 8), ), ) def test_keypoint_rcnn_fpn_backbones(model_name, param_groups_len): backbone_fn = getattr(models.torchvision.keypoint_rcnn.backbones, model_name) backbone = backbone_fn(pretrained=False) model = keypoint_rcnn.model(num_keypoints=2, num_classes=4, backbone=backbone) assert len(model.param_groups()) == param_groups_len
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,389
cnry/icevision
refs/heads/master
/icevision/models/fastai/unet/fastai/callbacks.py
__all__ = ["UnetCallback"] from icevision.imports import * class UnetCallback(fastai.Callback): def before_batch(self): assert len(self.xb) == len(self.yb) == 1 self.learn.records = self.yb[0] self.learn.yb = (self.xb[0][1],) self.learn.xb = (self.xb[0][0],)
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,390
cnry/icevision
refs/heads/master
/icevision/models/torchvision/retinanet/prediction.py
__all__ = [ "predict", "predict_from_dl", "convert_raw_prediction", "convert_raw_predictions", "end2end_detect", ] from icevision.models.torchvision.faster_rcnn.prediction import *
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,391
cnry/icevision
refs/heads/master
/icevision/models/fastai/unet/fastai/learner.py
__all__ = ["learner"] from icevision.imports import * from icevision.engines.fastai import * from icevision.models.fastai.unet.fastai.callbacks import * def learner( dls: List[Union[DataLoader, fastai.DataLoader]], model: nn.Module, cbs=None, loss_func=fastai.CrossEntropyLossFlat(axis=1), **kwargs, ): cbs = L(UnetCallback()) + L(cbs) learn = adapted_fastai_learner( dls=dls, model=model, cbs=cbs, loss_func=loss_func, **kwargs, ) return learn
{"/icevision/models/fastai/unet/fastai/__init__.py": ["/icevision/models/fastai/unet/fastai/callbacks.py", "/icevision/models/fastai/unet/fastai/learner.py"], "/icevision/models/fastai/unet/fastai/learner.py": ["/icevision/models/fastai/unet/fastai/callbacks.py"]}
13,465
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/miri/test_sloperpipeline.py
from glob import glob import os import pytest from jwst.pipeline import Detector1Pipeline from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestMIRISloperPipeline(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_sloperpipeline','truth'] test_dir = 'test_sloperpipeline' def test_gain_scale_naming(self): """ Regression test for gain_scale naming when results are requested to be saved for the gain_scale step. """ expfile = 'jw00001001001_01101_00001_MIRIMAGE' input_file = self.get_data(self.test_dir, expfile+'_uncal.fits') input_name = os.path.basename(input_file) step = Detector1Pipeline() step.group_scale.skip = True step.dq_init.skip = True step.saturation.skip = True step.ipc.skip = True step.superbias.skip = True step.refpix.skip = True step.rscd.skip = True step.firstframe.skip = True step.lastframe.skip = True step.linearity.skip = True step.dark_current.skip = True step.persistence.skip = True step.jump.skip = True step.ramp_fit.skip = False step.gain_scale.skip = False step.gain_scale.save_results = True step.run(input_file) files = glob('*.fits') if input_name in files: files.remove(input_name) output_file = expfile + '_gain_scale.fits' assert output_file in files files.remove(output_file) output_file = expfile + '_gain_scaleints.fits' assert output_file in files files.remove(output_file) assert not len(files) def test_detector1pipeline1(self): """ Regression test of calwebb_detector1 pipeline performed on MIRI data. """ input_file = self.get_data(self.test_dir, 'jw00001001001_01101_00001_MIRIMAGE_uncal.fits') step = Detector1Pipeline() step.save_calibrated_ramp = True step.ipc.skip = True step.refpix.odd_even_columns = True step.refpix.use_side_ref_pixels = True step.refpix.side_smoothing_length=11 step.refpix.side_gain=1.0 step.refpix.odd_even_rows = True step.persistence.skip = True step.jump.rejection_threshold = 250.0 step.ramp_fit.save_opt = False step.output_file='jw00001001001_01101_00001_MIRIMAGE' step.suffix='rate' step.run(input_file) outputs = [('jw00001001001_01101_00001_MIRIMAGE_ramp.fits', 'jw00001001001_01101_00001_MIRIMAGE_uncal_jump.fits'), ('jw00001001001_01101_00001_MIRIMAGE_rateints.fits', 'jw00001001001_01101_00001_MIRIMAGE_uncal_integ.fits'), ('jw00001001001_01101_00001_MIRIMAGE_rate.fits', 'jw00001001001_01101_00001_MIRIMAGE_uncal_MiriSloperPipeline.fits') ] self.compare_outputs(outputs) def test_detector1pipeline2(self): """ Regression test of calwebb_detector1 pipeline performed on MIRI data. """ input_file = self.get_data(self.test_dir, 'jw80600012001_02101_00003_mirimage_uncal.fits') step = Detector1Pipeline() step.save_calibrated_ramp = True step.ipc.skip = True step.refpix.odd_even_columns = True step.refpix.use_side_ref_pixels = True step.refpix.side_smoothing_length=11 step.refpix.side_gain=1.0 step.refpix.odd_even_rows = True step.persistence.skip = True step.jump.rejection_threshold = 250.0 step.ramp_fit.save_opt = False step.output_file='jw80600012001_02101_00003_mirimage' step.suffix='rate' step.run(input_file) outputs = [('jw80600012001_02101_00003_mirimage_ramp.fits', 'jw80600012001_02101_00003_mirimage_ramp.fits'), ('jw80600012001_02101_00003_mirimage_rateints.fits', 'jw80600012001_02101_00003_mirimage_rateints.fits'), ('jw80600012001_02101_00003_mirimage_rate.fits', 'jw80600012001_02101_00003_mirimage_rate.fits') ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,466
mperrin/jwst
refs/heads/master
/jwst/lib/exposure_types.py
""" This module contains lists of modes grouped in different ways """ from ..associations.lib.dms_base import (ACQ_EXP_TYPES, IMAGE2_SCIENCE_EXP_TYPES, IMAGE2_NONSCIENCE_EXP_TYPES, SPEC2_SCIENCE_EXP_TYPES) IMAGING_TYPES = set(tuple(ACQ_EXP_TYPES) + tuple(IMAGE2_SCIENCE_EXP_TYPES) + tuple(IMAGE2_NONSCIENCE_EXP_TYPES) + ('fgs_image', 'fgs_focus')) SPEC_TYPES = SPEC2_SCIENCE_EXP_TYPES # FGS guide star exposures FGS_GUIDE_EXP_TYPES = [ 'fgs_acq1', 'fgs_acq2', 'fgs_fineguide', 'fgs_id-image', 'fgs_id-stack', 'fgs_track', ] def is_moving_target(input_models): """ Determine if a moving target exposure.""" model = input_models[0] if hasattr(model.meta.target, 'type') and \ model.meta.target.type is not None and model.meta.target.type.lower() == 'moving': return True return False
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,467
mperrin/jwst
refs/heads/master
/jwst/outlier_detection/tests/test_outlier_detection.py
import pytest import numpy as np from scipy.ndimage.filters import gaussian_filter from jwst.outlier_detection.outlier_detection import flag_cr from jwst import datamodels @pytest.fixture def sci_blot_image_pair(): """Provide a science and blotted ImageModel pair.""" shape = (10, 10) sci = datamodels.ImageModel(shape) # Populate keywords sci.meta.exposure.exposure_time = 1 # Add poisson noise to image data p = np.random.poisson(size=shape, lam=1e3) sci.data = p / p.mean() - 1 # The blot image is just a smoothed version of the science image blot = sci.copy() blot.data = gaussian_filter(blot.data, sigma=3) return sci, blot def test_flag_cr(sci_blot_image_pair): """Test the flag_cr function. Test logic, not the actual noise model.""" sci, blot = sci_blot_image_pair assert (sci.dq == 0).all() # Add some background sci.data += 3 blot.data += 3 # Drop a CR on the science array sci.data[5, 5] += 10 flag_cr(sci, blot) assert sci.dq[5, 5] > 0 def test_flag_cr_with_subtracted_background(sci_blot_image_pair): """Test the flag_cr function on background-subtracted data""" sci, blot = sci_blot_image_pair sci.meta.background.subtracted = True sci.meta.background.level = 3 # Drop a CR on the science array sci.data[5, 5] += 10 flag_cr(sci, blot) assert sci.dq[5, 5] > 0
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,468
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/associations/test_level3_product_names.py
import pytest import re from jwst.associations.tests.helpers import ( func_fixture, generate_params, registry_level3_only, t_path, ) from jwst.associations import (AssociationPool, generate) from jwst.associations.lib.dms_base import DMSAttrConstraint LEVEL3_PRODUCT_NAME_REGEX = ( r'jw' r'(?P<program>\d{5})' r'-(?P<acid>[a-z]\d{3,4})' r'_(?P<target>(?:t\d{3})|(?:\{source_id\}))' r'(?:-(?P<epoch>epoch\d+))?' r'_(?P<instrument>.+?)' r'_(?P<opt_elem>.+)' ) LEVEL3_PRODUCT_NAME_NO_OPTELEM_REGEX = ( r'jw' r'(?P<program>\d{5})' r'-(?P<acid>[a-z]\d{3,4})' r'_(?P<target>(?:t\d{3})|(?:s\d{5}))' r'(?:-(?P<epoch>epoch\d+))?' r'_(?P<instrument>.+?)' ) # Null values EMPTY = (None, '', 'NULL', 'Null', 'null', 'F', 'f', 'N', 'n') pool_file = func_fixture( generate_params, scope='module', params=[ t_path('data/mega_pool.csv'), ] ) global_constraints = func_fixture( generate_params, scope='module', params=[ DMSAttrConstraint( name='asn_candidate', value=['.+o002.+'], sources=['asn_candidate'], force_unique=True, is_acid=True, evaluate=True, ), ] ) @pytest.mark.slow def test_level35_names(pool_file): rules = registry_level3_only() pool = AssociationPool.read(pool_file) asns = generate(pool, rules) for asn in asns: product_name = asn['products'][0]['name'] if asn['asn_rule'] == 'Asn_IFU': m = re.match(LEVEL3_PRODUCT_NAME_NO_OPTELEM_REGEX, product_name) else: m = re.match(LEVEL3_PRODUCT_NAME_REGEX, product_name) assert m is not None
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,469
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py
import pytest from jwst.pipeline.calwebb_image2 import Image2Pipeline from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestImage2Pipeline(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_image2pipeline', 'truth'] def test_image2pipeline2b(self): """ Regression test of calwebb_image2 pipeline performed on NIRCam data, using a multiple integration rate (rateints) file as input. """ input_file = self.get_data('test_image2pipeline', 'jw82500001003_02101_00001_NRCALONG_rateints.fits') output_file = 'jw82500001003_02101_00001_NRCALONG_calints.fits' Image2Pipeline.call(input_file, output_file=output_file) outputs = [(output_file, 'jw82500001003_02101_00001_NRCALONG_calints_ref.fits', ['primary','sci','err','dq','area'] ) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,470
mperrin/jwst
refs/heads/master
/jwst/ami/nrm_model.py
# # A module for conveniently manipulating an 'NRM object' using the # Lacour-Greenbaum algorithm. First written by Alexandra Greenbaum in 2014. # # This module: # Defines mask geometry and detector-scale parameters # Simulates PSF (broadband or monochromatic) # Builds a fringe model - either by user definition, or automated to data # Fits model to data by least squares # # Algorithm documented in: Greenbaum, A. Z., Pueyo, L. P., # Sivaramakrishnan, A., and Lacour, S. ; Astrophysical Journal (submitted) 2014. # Developed with NASA APRA (AS, AZG), NSF GRFP (AZG), NASA Sagan (LP), and # French taxpayer (SL) support. # # Heritage mathematica nb from Alex Greenbaum & Laurent Pueyo # Heritage python by Alex Greenbaum & Anand Sivaramakrishnan Jan 2013 # - updated May 2013 to include hexagonal envelope # - updated (hard refactored) Oct-Nov 2014 Anand S. import logging import numpy as np from . import leastsqnrm as leastsqnrm from . import analyticnrm2 from . import utils from . import hexee from . import nrm_consts log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) class NrmModel: def __init__(self, mask=None, holeshape="circ", pixscale=hexee.mas2rad(65), rotate=False, over=1, flip=False, pixweight=None, scallist=None, rotlist_deg=None, phi="perfect"): """ Short Summary ------------- Set attributes of NrmModel class. Parameters ---------- mask: string keyword for built-in values holeshape: string shape of apertures pixscale: float initial estimate of pixel scale in radians rotate: float initial estimate of rotation in radians over: integer oversampling factor flip: Boolean, default=False change sign of 2nd coordinate of holes pixweight: 2D float array, default is None weighting array scallist: float 1D array candidate relative pixel scales rotlist_deg: float 1D array Search window for rotation fine-tuning, in degrees phi: float 1D array distance of fringe from hole center in units of waves """ self.holeshape = holeshape self.pixel = pixscale self.over = over self.maskname = mask self.pixweight = pixweight if mask.lower() == 'jwst': self.ctrs = np.array( [[ 0.00000000, -2.640000], [-2.2863100, 0.0000000], [ 2.2863100 , -1.3200001], [-2.2863100 , 1.3200001], [-1.1431500 , 1.9800000], [ 2.2863100 , 1.3200001], [ 1.1431500 , 1.9800000]] ) self.d = 0.80 self.D = 6.5 else: try: log.debug('mask.ctrs:%s', mask.ctrs) except AttributeError: raise AttributeError("mask must be either 'jwst' \ or NRM_mask_geometry object") log.debug('NrmModel: ctrs flipped in init for CV1, CV2') if rotate: log.info('Providing additional rotation %s degrees', rotate * 180. / np.pi) # Rotates vector counterclockwise in coordinates self.rotation = rotate self.ctrs = leastsqnrm.rotatevectors(self.ctrs, rotate) # From now on this 'rotated' set of centers is used as the # nominal, and rotation searches (using rotlist_rad) are # performed with this rotated version of the 'as designed' # mask.. In CV1 and CV2 the mask is "flipped" by # multiplying ctrs[:1] by -1... which places segment B4 # (the 6 o clock segment) at the top instead of at bottom # in traditional XY plots self.N = len(self.ctrs) if scallist is None: self.scallist = np.array([0.995, 0.998, 1.0, 1.002, 1.005, ]) else: self.scallist = scallist if rotlist_deg is None: self.rotlist_rad = np.array([-1.0,-0.5,0.0,0.5,1.0]) * np.pi / 180.0 else: self.rotlist_rad = rotlist_deg * np.pi / 180.0 if phi == "perfect": self.phi = np.zeros(len(self.ctrs)) elif phi == 'nb': self.phi = nrm_consts.phi_nb else: self.phi = phi def simulate(self, fov=None, bandpass=None, over=None, pixweight=None, pixel=None, rotate=False, centering="PIXELCENTERED"): """ Short Summary ------------- Simulate a psf using parameters input from the call and already stored in the object. It also generates a simulation fits header storing all of the parameters used to generate that psf. If the input bandpass is one number it will calculate a monochromatic PSF. Parameters ---------- fov: integer, default=None number of detector pixels on a side bandpass: 2D float array, default=None array of the form: [(weight1, wavl1), (weight2, wavl2), ...] over: integer Oversampling factor pixweight: 2D float array, default=None weighting array pixel: float, default=None pixel scale rotate: float, default=False, rotation angle in radians centering: string, default=None type of centerings Returns ------- Object's 'psf': float 2D array simulated psf """ # First set up conditions for choosing various parameters if fov is None: if not hasattr(self, 'fov'): log.critical('Field is not specified') return None else: self.fov_sim = self.fov log.debug('Using predefined FOV size: %s', self.fov) else: self.fov_sim = fov if hasattr(centering, '__iter__'): if centering == 'PIXELCENTERED': centering=(0.5, 0.5) elif centering == 'PIXELCORNER': centering=(0.0, 0.0) self.bandpass = bandpass if not hasattr(self, 'over'): if over is None: self.over = 1 else: self.over = over if self.over is None: self.over = over if pixweight is not None: self.over = self.pixweight.shape[0] self.phi = np.zeros(len(self.ctrs)) if rotate: # this is a 'temporary' rotation of self.ctrs # without altering self.ctrs self.rotate = rotate self.rotctrs = leastsqnrm.rotatevectors(self.ctrs, self.rotate) else: self.rotctrs = self.ctrs if pixel is None: self.pixel_sim = self.pixel else: self.pixel_sim = pixel # The polychromatic case: if hasattr(self.bandpass, '__iter__'): log.debug("------Simulating Polychromatic------") self.psf_over = np.zeros((self.over*self.fov_sim, self.over*self.fov_sim)) for w,l in self.bandpass: # w: weight, l: lambda (wavelength) self.psf_over += w*analyticnrm2.PSF(self.pixel_sim, self.fov_sim, self.over, self.rotctrs, self.d, l, self.phi, centering = centering, shape=self.holeshape) log.debug("BINNING UP TO PIXEL SCALE") # The monochromatic case if bandpass input is a single wavelength else: self.lam = bandpass log.debug("Calculating Oversampled PSF") self.psf_over = analyticnrm2.PSF(self.pixel_sim, self.fov_sim, self.over, self.rotctrs, self.d, self.lam, self.phi, centering=centering, shape=self.holeshape) self.psf = utils.rebin(self.psf_over, (self.over, self.over)) return self.psf def make_model(self, fov=None, bandpass=None, over=False, centering='PIXELCENTERED', pixweight=None, pixscale=None, rotate=False, flip=False): """ Short Summary ------------- Generates the fringe model with the attributes of the object using a bandpass as a list of tuples. Parameters ---------- fov: integer, default=None number of detector pixels on a side bandpass: 2D float array, default=None array of the form: [(weight1, wavl1), (weight2, wavl2), ...] over: integer oversampling factor centering: string, default=None type of centering pixweight: 2D float array, default=None weighting array pixscale: float, default=None pixel scale rotate: float, default=False rotation angle in radians flip: Boolean, default=False change sign of 2nd coordinate of holes Returns ------- Object's 'model': fringe model Generated fringe model """ if fov: self.fov = fov if over is False: self.over = 1 else: self.over = over if pixweight is not None: self.over = self.pixweight.shape[0] if hasattr(self, 'pixscale_measured'): if self.pixscale_measured is not None: self.modelpix = self.pixscale_measured if pixscale is None: self.modelpix = self.pixel else: self.modelpix = pixscale if rotate: if flip is True: self.modelctrs = leastsqnrm.flip( leastsqnrm.rotatevectors(self.ctrs, self.rot_measured)) else: self.modelctrs = leastsqnrm.rotatevectors( self.ctrs, self.rot_measured) else: self.modelctrs = self.ctrs if not hasattr(bandpass, '__iter__'): self.lam = bandpass self.model = np.ones((self.fov, self.fov, self.N*(self.N-1)+2)) self.model_beam, self.fringes = leastsqnrm.model_array( self.modelctrs, self.lam, self.over, self.modelpix, self.fov, self.d, shape=self.holeshape, centering=centering) log.debug("centering: {0}".format(centering)) log.debug("what primary beam has the model created?"+ " {0}".format(self.model_beam)) # this routine multiplies the envelope by each fringe "image" self.model_over = leastsqnrm.multiplyenv(self.model_beam, self.fringes) self.model = np.zeros((self.fov,self.fov, self.model_over.shape[2])) # loop over slices "sl" in the model for sl in range(self.model_over.shape[2]): self.model[:,:,sl] = utils.rebin( self.model_over[:,:,sl], (self.over, self.over)) return self.model else: self.bandpass = bandpass # The model shape is (fov) x (fov) x (# solution coefficients) # the coefficient refers to the terms in the analytic equation # There are N(N-1) independent pistons, double-counted by cosine # and sine, one constant term and a DC offset. self.model = np.ones((self.fov, self.fov, self.N*(self.N-1)+2)) self.model_beam = np.zeros((self.over*self.fov, self.over*self.fov)) self.fringes = np.zeros(( self.N*(self.N-1)+1, self.over*self.fov, self.over*self.fov)) for w,l in self.bandpass: # w: weight, l: lambda (wavelength) # model_array returns the envelope and fringe model pb, ff = leastsqnrm.model_array( self.modelctrs, l, self.over, self.modelpix, self.fov, self.d, shape=self.holeshape, centering=centering) log.debug("centering: {0}".format(centering)) log.debug("what primary beam has the model created? {0}".format(pb)) self.model_beam += pb self.fringes += ff # this routine multiplies the envelope by each fringe "image" self.model_over = leastsqnrm.multiplyenv(pb, ff) model_binned = np.zeros(( self.fov,self.fov, self.model_over.shape[2])) # loop over slices "sl" in the model for sl in range(self.model_over.shape[2]): model_binned[:,:,sl] = utils.rebin( self.model_over[:,:,sl], (self.over, self.over)) self.model += w*model_binned return self.model def fit_image(self, image, reference=None, pixguess=None, rotguess=0, modelin=None, weighted=False, centering='PIXELCENTERED', savepsfs=True): """ Short Summary ------------- Run a least-squares fit on an input image; find the appropriate wavelength scale and rotation. If a model is not specified then this method will find the appropriate wavelength scale, rotation (and hopefully centering as well -- This is not written into the object yet, but should be soon). Parameters ---------- image: 2D float array input image reference: 2D float array input reference image pixguess: float estimate of pixel scale of the data rotguess: float estimate of rotation modelin: 2D array optional model image weighted: boolean use weighted operations in the least squares routine centering: string, default=None type of centering savepsfs: boolean save the psfs for writing to file (currently unused) Returns ------- None """ self.model_in = modelin self.weighted = weighted self.saveval = savepsfs if modelin is None: # No model provided # Perform a set of automatic routines # A Cleaned up version of your image to enable Fourier fitting for # centering crosscorrelation with FindCentering() and # magnification and rotation via improve_scaling(). if reference is None: self.reference = image if np.isnan(image.any()): raise ValueError("Must have non-NaN image to "+ "crosscorrelate for scale. Reference "+ "image should also be centered. Get to it.") else: self.reference = reference if pixguess is None or rotguess is None: raise ValueError("MUST SPECIFY GUESSES FOR PIX & ROT") self.improve_scaling(self.reference, scaleguess=self.pixel, rotstart=rotguess, centering=centering) self.pixscale_measured = self.pixscale_factor*self.pixel self.fov = image.shape[0] self.fittingmodel = self.make_model(self.fov, bandpass=self.bandpass, over=self.over, rotate=True, centering=centering, pixscale=self.pixscale_measured) else: self.fittingmodel = modelin if weighted is not False: self.soln, self.residual = leastsqnrm.weighted_operations(image, self.fittingmodel, weights=self.weighted) else: self.soln, self.residual, self.cond = leastsqnrm.matrix_operations( image, self.fittingmodel) self.rawDC = self.soln[-1] self.flux = self.soln[0] self.soln = self.soln/self.soln[0] self.deltapsin = leastsqnrm.sin2deltapistons(self.soln) self.deltapcos = leastsqnrm.cos2deltapistons(self.soln) self.fringeamp, self.fringephase = leastsqnrm.tan2visibilities(self.soln) self.piston = utils.fringes2pistons(self.fringephase, len(self.ctrs)) self.closurephase = leastsqnrm.closurephase(self.fringephase, N=self.N) self.redundant_cps = leastsqnrm.redundant_cps(self.fringephase, N=self.N) self.redundant_cas = leastsqnrm.return_CAs(self.fringeamp, N=self.N) def create_modelpsf(self): """ Short Summary ------------- Make an image from the object's model and fit solutions, by setting the NrmModel object's modelpsf attribute Parameters ---------- None Returns ------- None """ try: self.modelpsf = np.zeros((self.fov, self.fov)) except AttributeError: self.modelpsf = np.zeros((self.fov_sim, self.fov_sim)) for ind, coeff in enumerate(self.soln): self.modelpsf += self.flux * coeff * self.fittingmodel[:, :, ind] return None def improve_scaling(self, img, scaleguess=None, rotstart=0.0, centering='PIXELCENTERED'): """ Short Summary ------------- Determine the scale and rotation that best fits the data. Correlations are calculated in the image plane, in anticipation of data with many bad pixels. Parameters ---------- img: 2D float array input image scaleguess: float initial estimate of pixel scale in radians rotstart: float estimate of rotation centering: string, default='PIXELCENTERED' type of centering Returns ------- self.pixscale_factor: float improved estimate of pixel scale in radians self.rot_measured: float value of mag at the extreme value of rotation from quadratic fit self.gof: float goodness of fit """ if not hasattr(self, 'bandpass'): raise ValueError("This object has no specified bandpass/wavelength") reffov = img.shape[0] scal_corrlist = np.zeros((len(self.scallist), reffov, reffov)) pixscl_corrlist = scal_corrlist.copy() scal_corr = np.zeros(len(self.scallist)) self.pixscl_corr = scal_corr.copy() # User can specify a reference set of phases (m) at an earlier point so # that all PSFs are simulated with those phase pistons (e.g. measured # from data at an earlier iteration if not hasattr(self, 'refphi'): self.refphi = np.zeros(len(self.ctrs)) else: pass self.pixscales = np.zeros(len(self.scallist)) for q, scal in enumerate(self.scallist): self.test_pixscale = self.pixel*scal self.pixscales[q] = self.test_pixscale psf = self.simulate(bandpass=self.bandpass, fov=reffov, pixel = self.test_pixscale, centering=centering) pixscl_corrlist[q,:,:] = run_data_correlate(img,psf) self.pixscl_corr[q] = np.max(pixscl_corrlist[q]) if True in np.isnan(self.pixscl_corr): raise ValueError("Correlation produced NaNs, check your work!") self.pixscale_optimal, scal_maxy = utils.findmax( mag=self.pixscales, vals=self.pixscl_corr) self.pixscale_factor = self.pixscale_optimal / self.pixel radlist = self.rotlist_rad corrlist = np.zeros((len(radlist), reffov, reffov)) self.corrs = np.zeros(len(radlist)) self.rots = radlist for q,rad in enumerate(radlist): psf = self.simulate(bandpass=self.bandpass, fov=reffov, pixel=self.pixscale_optimal, rotate=rad, centering=centering) corrlist[q,:,:] = run_data_correlate(psf, img) self.corrs[q] = np.max(corrlist[q]) self.rot_measured, maxy = utils.findmax(mag=self.rots, vals = self.corrs) self.refpsf = self.simulate(bandpass=self.bandpass, pixel=self.pixscale_factor*self.pixel, fov=reffov, rotate=self.rot_measured, centering=centering) try: self.gof = goodness_of_fit(img,self.refpsf) except Exception: self.gof = False return self.pixscale_factor, self.rot_measured, self.gof def makedisk(N, R, ctr=(0,0)): """ Short Summary ------------- Calculate a 'disk', an array whose values =1 in a circular region near the center of the array, and =0 elsewhere. (Anand's emailed version) Parameters ---------- N: integer size of 1 dimension of the array to be returned R: integer radius of disk ctr: (integer, integer) center of disk array: 'ODD' or 'EVEN' parity of size of edge Returns ------- array: 2D integer array """ if N%2 == 1: # odd M = (N-1)/2 xx = np.linspace(-M-ctr[0],M-ctr[0],N) yy = np.linspace(-M-ctr[1],M-ctr[1],N) if N%2 == 0: # even M = N/2 xx = np.linspace(-M-ctr[0],M-ctr[0]-1,N) yy = np.linspace(-M-ctr[1],M-ctr[1]-1,N) (x,y) = np.meshgrid(xx, yy.T) r = np.sqrt((x**2)+(y**2)) array = np.zeros((N,N)) array[r<R] = 1 return array def goodness_of_fit(data, bestfit, diskR=8): """ Short Summary ------------- Calculate goodness of fit between the data and the fit. Parameters ---------- data: 2D float array input image bestfit: 2D float array fit to input image diskR: integer radius of disk Returns ------- gof: float goodness of fit """ mask = np.ones(data.shape) + makedisk(data.shape[0], 2) -\ makedisk(data.shape[0], diskR) difference = np.ma.masked_invalid(mask * (bestfit - data)) masked_data = np.ma.masked_invalid(mask * data) gof = abs(difference).sum() / abs(masked_data).sum() return gof def run_data_correlate(data, model): """ Short Summary ------------- Calculate correlation between data and model Parameters ---------- data: 2D float array reference image model: 2D float array simulated psf Returns ------- cor: 2D float array correlation between data and model """ sci = data log.debug('shape sci: %s', np.shape(sci)) cor = utils.rcrosscorrelate(sci, model) return cor
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,471
mperrin/jwst
refs/heads/master
/jwst/master_background/__init__.py
from .master_background_step import MasterBackgroundStep __all__ = ['MasterBackgroundStep']
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,472
mperrin/jwst
refs/heads/master
/jwst/lib/basic_utils.py
"""General utility objects""" import re def multiple_replace(string, rep_dict): """Single-pass replacement of multiple substrings Similar to `str.replace`, except that a dictionary of replacements can be specified. The replacements are done in a single-pass. This means that a previous replacement will not be replaced by a subsequent match. Parameters ---------- string: str The source string to have replacements done on it. rep_dict: dict The replacements were key is the input substring and value is the replacement Returns ------- replaced: str New string with the replacements done Examples -------- Basic example that also demonstrates the single-pass nature. If the replacements where chained, the result would have been 'lamb lamb' >>> multiple_replace('button mutton', {'but': 'mut', 'mutton': 'lamb'}) 'mutton lamb' """ pattern = re.compile( "|".join([re.escape(k) for k in sorted(rep_dict,key=len,reverse=True)]), flags=re.DOTALL ) return pattern.sub(lambda x: rep_dict[x.group(0)], string) class LoggingContext: """Logging context manager Keep logging configuration within a context Based on the Python 3 Logging Cookbook example Parameters ========== logger: logging.Logger The logger to modify. level: int The log level to set. handler: logging.Handler The handler to use. close: bool Close the handler when done. """ def __init__(self, logger, level=None, handler=None, close=True): self.logger = logger self.level = level self.handler = handler self.close = close self.old_level = None def __enter__(self): if self.level is not None: self.old_level = self.logger.level self.logger.setLevel(self.level) if self.handler: self.logger.addHandler(self.handler) def __exit__(self, et, ev, tb): if self.level is not None: self.logger.setLevel(self.old_level) if self.handler: self.logger.removeHandler(self.handler) if self.handler and self.close: self.handler.close() # implicit return of None => don't swallow exceptions
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,473
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py
import pytest from jwst.pipeline.calwebb_spec2 import Spec2Pipeline from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestSpec2Pipeline(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_spec2pipeline', 'truth'] test_dir = 'test_spec2pipeline' def test_nis_wfss_spec2(self): """ Regression test of calwebb_spec2 pipeline performed on NIRISS WFSS data. """ # Collect data asn_file = self.get_data(self.test_dir, 'jw87600-a3001_20171109T145456_spec2_001_asn.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) # Run the step collect_pipeline_cfgs('cfgs') Spec2Pipeline.call(asn_file, config_file='cfgs/calwebb_spec2.cfg', save_bsub=True) # Test results. outputs = [('jw87600017001_02101_00002_nis_cal.fits', 'jw87600017001_02101_00002_nis_cal_ref.fits'), ('jw87600017001_02101_00002_nis_x1d.fits', 'jw87600017001_02101_00002_nis_x1d_ref.fits')] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,474
mperrin/jwst
refs/heads/master
/jwst/regtest/test_miri_image_detector1.py
import os import pytest from astropy.io.fits.diff import FITSDiff from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step @pytest.fixture(scope="module") def run_pipeline(jail, rtdata_module): """Run calwebb_detector1 pipeline on MIRI imaging data.""" rtdata = rtdata_module rtdata.get_data("miri/image/jw00001001001_01101_00001_MIRIMAGE_uncal.fits") collect_pipeline_cfgs("config") args = ["config/calwebb_detector1.cfg", rtdata.input, "--steps.dq_init.save_results=True", "--steps.lastframe.save_results=True", "--steps.firstframe.save_results=True", "--steps.saturation.save_results=True", "--steps.rscd.save_results=True", "--steps.linearity.save_results=True", "--steps.dark_current.save_results=True", "--steps.refpix.save_results=True", "--steps.jump.rejection_threshold=25", "--steps.jump.save_results=True", "--steps.ramp_fit.save_opt=True", "--steps.ramp_fit.save_results=True"] Step.from_cmdline(args) return rtdata @pytest.mark.bigdata @pytest.mark.parametrize("output", ['rate', 'rateints', 'linearity', 'rscd', 'dq_init', 'firstframe', 'lastframe', 'saturation', 'dark_current', 'refpix', 'jump', 'fitopt']) def test_miri_image_detector1(run_pipeline, request, fitsdiff_default_kwargs, output): """ Regression test of calwebb_detector1 pipeline performed on MIRI data. """ rtdata = run_pipeline rtdata.output = "jw00001001001_01101_00001_MIRIMAGE_" + output + ".fits" rtdata.get_truth(os.path.join("truth/test_miri_image_detector1", "jw00001001001_01101_00001_MIRIMAGE_" + output + ".fits")) diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report()
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,475
mperrin/jwst
refs/heads/master
/jwst/flatfield/flat_field_step.py
from ..stpipe import Step from .. import datamodels from . import flat_field # For the following types of data, it is OK -- and in some cases # required -- for the extract_2d step to have been run. For all # other types of data, the extract_2d step must not have been run. EXTRACT_2D_IS_OK = [ "NRS_BRIGHTOBJ", "NRS_FIXEDSLIT", "NRS_LAMP", "NRS_MSASPEC", ] # NIRSpec imaging types (see exp_type2transform in assign_wcs/nirspec.py) NRS_IMAGING_MODES = [ "NRS_CONFIRM", "NRS_FOCUS", "NRS_IMAGE", "NRS_MIMF", "NRS_MSATA", "NRS_TACONFIRM", "NRS_TACQ", "NRS_TASLIT", "NRS_WATA", ] # Supported NIRSpec spectrographic types. No flat fielding for NRS_AUTOFLAT NRS_SPEC_MODES = [ "NRS_BRIGHTOBJ", "NRS_FIXEDSLIT", "NRS_IFU", "NRS_MSASPEC", ] __all__ = ["FlatFieldStep"] class FlatFieldStep(Step): """Flat-field a science image using a flatfield reference image. """ spec = """ save_interpolated_flat = boolean(default=False) # Save interpolated NRS flat """ reference_file_types = ["flat", "fflat", "sflat", "dflat"] # Define a suffix for optional saved output of the interpolated flat for NRS flat_suffix = 'interpolatedflat' def process(self, input): input_model = datamodels.open(input) exposure_type = input_model.meta.exposure.type.upper() self.log.debug("Input is {} of exposure type {}".format( input_model.__class__.__name__, exposure_type)) if input_model.meta.instrument.name.upper() == "NIRSPEC": if (exposure_type not in NRS_SPEC_MODES and exposure_type not in NRS_IMAGING_MODES): self.log.warning("Exposure type is %s; flat-fielding will be " "skipped because it is not currently " "supported for this mode.", exposure_type) return self.skip_step(input_model) # Check whether extract_2d has been run. if (input_model.meta.cal_step.extract_2d == 'COMPLETE' and not exposure_type in EXTRACT_2D_IS_OK): self.log.warning("The extract_2d step has been run, but for " "%s data it should not have been run, so ...", exposure_type) self.log.warning("flat fielding will be skipped.") return self.skip_step(input_model) # Get reference file paths reference_file_names = {} for reftype in self.reference_file_types: reffile = self.get_reference_file(input_model, reftype) reference_file_names[reftype] = reffile if reffile != 'N/A' else None # Define mapping between reftype and datamodel type model_type = dict( flat=datamodels.FlatModel, fflat=datamodels.NirspecFlatModel, sflat=datamodels.NirspecFlatModel, dflat=datamodels.NirspecFlatModel, ) if exposure_type == "NRS_MSASPEC": model_type["fflat"] = datamodels.NirspecQuadFlatModel # Open the relevant reference files as datamodels reference_file_models = {} for reftype, reffile in reference_file_names.items(): if reffile is not None: reference_file_models[reftype] = model_type[reftype](reffile) self.log.debug('Using %s reference file: %s', reftype.upper(), reffile) else: reference_file_models[reftype] = None # Do the flat-field correction output_model, interpolated_flats = flat_field.do_correction( input_model, **reference_file_models, ) # Close the input and reference files input_model.close() try: for model in reference_file_models.values(): model.close() except AttributeError: pass if self.save_interpolated_flat and interpolated_flats is not None: self.log.info("Writing interpolated flat field.") self.save_model(interpolated_flats, suffix=self.flat_suffix) interpolated_flats.close() return output_model def skip_step(self, input_model): """Set the calibration switch to SKIPPED. This method makes a copy of input_model, sets the calibration switch for the flat_field step to SKIPPED in the copy, closes input_model, and returns the copy. """ result = input_model.copy() result.meta.cal_step.flat_field = "SKIPPED" input_model.close() return result
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,476
mperrin/jwst
refs/heads/master
/jwst/ami/analyticnrm2.py
#! /usr/bin/env python # Heritage mathematia nb from Alex & Laurent # Python by Alex Greenbaum & Anand Sivaramakrishnan Jan 2013 # updated May 2013 to include hexagonal envelope from . import hexee import logging import numpy as np import scipy.special from . import leastsqnrm log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) def Jinc(x, y): """ Short Summary ------------- Compute 2d Jinc for given coordinates Parameters ---------- x,y: floats input coordinates Returns ------- jinc_2d: float array 2d Jinc at the given coordinates, with NaNs replaced by pi/4. """ R = (Jinc.d / Jinc.lam) * Jinc.pitch * \ np.sqrt((x - Jinc.offx)*(x - Jinc.offx) + \ (y - Jinc.offy)*(y - Jinc.offy)) jinc_2d = leastsqnrm.replacenan(scipy.special.jv(1, np.pi * R)/(2.0 * R)) return jinc_2d def phasor(kx, ky, hx, hy, lam, phi, pitch): """ Short Summary ------------- Calculate wavefront for a single hole ?? Parameters ---------- kx, ky: float image plane coords in units of sampling pitch (oversampled, or not) hx, hy: float hole centers in meters lam: float wavelength phi: float distance of fringe from hole center in units of waves pitch: float sampling pitch in radians in image plane Returns ------- phasor: complex Calculate wavefront for a single hole """ return np.exp(-2 * np.pi * 1j * ((pitch * kx * hx + pitch * ky * hy) / lam + (phi / lam))) def interf(kx, ky): """ Short Summary ------------- Calculate interference for all holes. Parameters ---------- kx, ky: float, float x-component and y-component of image plane (spatial frequency) vector Returns ------- interference: 2D complex array interference for all holes """ interference = 0j for hole, ctr in enumerate(interf.ctrs): interference += phasor((kx - interf.offx), (ky - interf.offy), ctr[0], ctr[1], interf.lam, interf.phi[hole], interf.pitch) return interference def ASF(pixel, fov, oversample, ctrs, d, lam, phi, centering=(0.5, 0.5)): """ Short Summary ------------- Calculate the Amplitude Spread Function (a.k.a. image plane complex amplitude) for a circular aperture Parameters ---------- pixel: float pixel scale fov: integer number of detector pixels on a side oversample: integer oversampling factor ctrs: float, float coordinates of hole center d: float hole diameter lam: float wavelength phi: float distance of fringe from hole center in units of waves centering: string if set to 'PIXELCENTERED' or unspecified, the offsets will be set to (0.5,0.5); if set to 'PIXELCORNER', the offsets will be set to (0.0,0.0). Returns ------- asf: 2D complex array Amplitude Spread Function (a.k.a. image plane complex amplitude) for a circular aperture """ if centering == 'PIXELCENTERED': off_x = 0.5 off_y = 0.5 elif centering == 'PIXELCORNER': off_x = 0.0 off_y = 0.0 else: off_x, off_y = centering log.debug('ASF centering %s:', centering) log.debug('ASF offsets %s %s:', off_x, off_y) # Jinc parameters Jinc.lam = lam Jinc.offx = oversample * fov / 2.0 - off_x # in pixels Jinc.offy = oversample * fov / 2.0 - off_y Jinc.pitch = pixel / float(oversample) Jinc.d = d primarybeam = np.fromfunction(Jinc, (int((oversample * fov)), int((oversample * fov)))) primarybeam = primarybeam.transpose() # interference terms' parameters interf.lam = lam interf.offx = oversample * fov / 2.0 - off_x # in pixels interf.offy = oversample * fov / 2.0 - off_y interf.pitch = pixel / float(oversample) interf.ctrs = ctrs interf.phi = phi fringing = np.fromfunction(interf, (int((oversample * fov)), int((oversample * fov)))) fringing = fringing.transpose() asf = primarybeam * fringing return asf def ASFfringe(pixel, fov, oversample, ctrs, d, lam, phi, centering=(0.5, 0.5)): """ Short Summary ------------- Amplitude Spread Function (a.k.a. image plane complex amplitude) for a fringe Parameters ---------- pixel: float pixel scale fov: integer number of detector pixels on a side oversample: integer oversampling factor ctrs: 2D float array centers of holes d: float hole diameter lam: float wavelength phi: float distance of fringe from hole center in units of waves centering: string if set to 'PIXELCENTERED' or unspecified, the offsets will be set to (0.5,0.5); if set to 'PIXELCORNER', the offsets will be set to (0.0,0.0). Returns ------- fringing: 2D complex array Amplitude Spread Function (a.k.a. image plane complex amplitude) for a fringe """ if centering == 'PIXELCENTERED': off_x = 0.5 off_y = 0.5 elif centering == 'PIXELCORNER': off_x = 0.0 off_y = 0.0 else: off_x, off_y = centering log.debug('ASFfringe centering %s:', centering) log.debug('ASFfringe offsets %s %s:', off_x, off_y) # Jinc parameters Jinc.lam = lam Jinc.offx = oversample * fov / 2.0 - off_x # in pixels Jinc.offy = oversample * fov / 2.0 - off_y Jinc.pitch = pixel / float(oversample) Jinc.d = d # interference terms' parameters interf.lam = lam interf.offx = oversample * fov / 2.0 - off_x # in pixels interf.offy = oversample * fov / 2.0 - off_y interf.pitch = pixel / float(oversample) interf.ctrs = ctrs interf.phi = phi fringing = np.fromfunction(interf, (int((oversample * fov)), int((oversample * fov)))) fringing = fringing.transpose() return fringing def ASFhex(pixel, fov, oversample, ctrs, d, lam, phi, centering='PIXELCENTERED'): """ Short Summary ------------- Amplitude Spread Function (a.k.a. image plane complex amplitude) for a hexagonal aperture Parameters ---------- pixel: float pixel scale fov: integer number of detector pixels on a side oversample: integer oversampling factor ctrs: 2D float array centers of holes d: float flat-to-flat distance across hexagon lam: float wavelength phi: float distance of fringe from hole center in units of waves centering: string type of centering Returns ------- asf: 2D complex array Amplitude Spread Function (a.k.a. image plane complex amplitude) for a hexagonal aperture """ log.debug('centering: %s', centering) if centering == 'PIXELCENTERED': off_x = 0.5 off_y = 0.5 elif centering == 'PIXELCORNER': off_x = 0.0 off_y = 0.0 else: off_x, off_y = centering #Hex kwargs offx = (float(oversample * fov) / 2.0) - off_x # in pixels offy = (float(oversample * fov) / 2.0) - off_y log.debug('ASF offsets for x and y in pixels: %s %s', offx, offy) log.debug('ASF centering:%s', centering) pitch = pixel / float(oversample) # interference terms' parameters interf.lam = lam interf.offx = (oversample * fov) / 2.0 - off_x # in pixels interf.offy = (oversample * fov) / 2.0 - off_y interf.pitch = pixel / float(oversample) interf.ctrs = ctrs interf.phi = phi primarybeam = hexee.hex_eeAG(s=(oversample * fov, oversample * fov), c=(offx, offy), d=d, lam=lam, pitch=pitch) fringing = np.fromfunction(interf, (int((oversample * fov)), int((oversample * fov)))) fringing = fringing.transpose() asf = primarybeam * fringing return asf def PSF(pixel, fov, oversample, ctrs, d, lam, phi, centering='PIXELCENTERED', shape='circ'): """ Short Summary ------------- Calculate the PSF for the requested shape Parameters ---------- pixel: float pixel scale fov: integer number of detector pixels on a side oversample: integer oversampling factor ctrs: 2D float array centers of holes d: float hole diameter for 'circ'; flat-to-flat distance across for 'hex' lam: float wavelength phi: float distance of fringe from hole center in units of waves centering: string type of centering shape: string shape of hole; possible values are 'circ', 'hex', and 'fringe' Returns ------- PSF - 2D float array """ if shape == 'circ': asf = ASF(pixel, fov, oversample, ctrs, d, lam, phi, centering) elif shape == 'hex': asf = ASFhex(pixel, fov, oversample, ctrs, d, lam, phi, centering) elif shape == 'fringe': # Alex: "not needed,only used for visualization" asf = ASFfringe(pixel, fov, oversample, ctrs, d, lam, phi, centering) else: log.critical('Pupil shape %s not supported', shape) log.debug('-----------------') log.debug(' PSF Parameters: ') log.debug('-----------------') log.debug('pixel: %s, fov: %s, oversampling: %s', pixel, fov, oversample) log.debug('d: %s, wavelength: %s, pistons: %s, shape: %s', d, lam, phi, shape) PSF_ = asf * asf.conj() return PSF_.real
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,477
mperrin/jwst
refs/heads/master
/jwst/datamodels/tests/test_level1b.py
"""Test Level1bModel""" import pytest import numpy as np from .. import Level1bModel @pytest.mark.xfail def test_no_zeroframe(): """Test for default zeroframe""" nx = 10 ny = 10 ngroups = 5 nints = 2 data = np.zeros((nints, ngroups, ny, nx), np.int16) model = Level1bModel(data) assert model.data.shape == (nints, ngroups, ny, nx) assert model.zeroframe.shape == (nints, ny, nx)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,478
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py
import pytest from jwst.pipeline import Spec2Pipeline from jwst.tests.base_classes import BaseJWSTTest from jwst.tests.base_classes import pytest_generate_tests # noqa: F401 @pytest.mark.bigdata class TestSpec2Pipeline(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_pipelines', 'truth'] test_dir = 'test_pipelines' # Specification of parameters for Spec2Pipeline tests params = {'test_spec2': # test_nrs_fs_multi_spec2_1: NIRSpec fixed-slit data [dict(input='jw00023001001_01101_00001_NRS1_rate.fits', outputs=[('jw00023001001_01101_00001_NRS1_cal.fits', 'jw00023001001_01101_00001_NRS1_cal_ref.fits'), ('jw00023001001_01101_00001_NRS1_s2d.fits', 'jw00023001001_01101_00001_NRS1_s2d_ref.fits'), ('jw00023001001_01101_00001_NRS1_x1d.fits', 'jw00023001001_01101_00001_NRS1_x1d_ref.fits') ], id="nirspec_fs_multi_1" ), # test_nrs_fs_multi_spec2_2: NIRSpec fixed-slit data dict(input= 'jwtest1013001_01101_00001_NRS1_rate.fits', outputs=[('jwtest1013001_01101_00001_NRS1_cal.fits', 'jwtest1013001_01101_00001_NRS1_cal_ref.fits'), ('jwtest1013001_01101_00001_NRS1_s2d.fits', 'jwtest1013001_01101_00001_NRS1_s2d_ref.fits'), ('jwtest1013001_01101_00001_NRS1_x1d.fits', 'jwtest1013001_01101_00001_NRS1_x1d_ref.fits') ], id="nirspec_fs_multi_2" ), # test_nrs_fs_multi_spec2_3: # NIRSpec fixed-slit data using the ALLSLITS subarray and detector NRS2 # NIRSpec fixed-slit data that uses a single-slit subarray (S200B1). dict(input= 'jw84600002001_02101_00001_nrs2_rate.fits', outputs=[('jw84600002001_02101_00001_nrs2_cal.fits', 'jw84600002001_02101_00001_nrs2_cal_ref.fits'), ('jw84600002001_02101_00001_nrs2_s2d.fits', 'jw84600002001_02101_00001_nrs2_s2d_ref.fits'), ('jw84600002001_02101_00001_nrs2_x1d.fits', 'jw84600002001_02101_00001_nrs2_x1d_ref.fits') ], id="nirspec_fs_multi_3" ), # test_nrs_ifu_spec2: NIRSpec IFU data dict(input= 'jw95175001001_02104_00001_nrs1_rate.fits', outputs=[('jw95175001001_02104_00001_nrs1_cal.fits', 'jw95175001001_02104_00001_nrs1_cal_ref.fits'), ('jw95175001001_02104_00001_nrs1_s3d.fits', 'jw95175001001_02104_00001_nrs1_s3d_ref.fits'), ('jw95175001001_02104_00001_nrs1_x1d.fits', 'jw95175001001_02104_00001_nrs1_x1d_ref.fits') ], id = "nirspec_ifu" ) ] } def test_spec2(self, input, outputs): """ Regression test of calwebb_spec2 pipeline performed on NIRSpec data. """ input_file = self.get_data(self.test_dir, input) step = Spec2Pipeline() step.save_bsub = True step.save_results = True step.resample_spec.save_results = True step.cube_build.save_results = True step.extract_1d.save_results = True step.run(input_file) self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,479
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/miri/test_miri_steps_single.py
import os import numpy as np from numpy.testing import assert_allclose import pytest from gwcs.wcstools import grid_from_bounding_box from ci_watson.artifactory_helpers import get_bigdata from jwst import datamodels from jwst.datamodels import ImageModel, RegionsModel, CubeModel from jwst.stpipe import crds_client from jwst.lib.set_telescope_pointing import add_wcs from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.assign_wcs import AssignWcsStep from jwst.cube_build import CubeBuildStep from jwst.linearity import LinearityStep from jwst.ramp_fitting import RampFitStep from jwst.master_background import MasterBackgroundStep @pytest.mark.bigdata class TestMIRIRampFit(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_ramp_fit', 'truth'] test_dir = 'test_ramp_fit' def test_ramp_fit_miri1(self): """ Regression test of ramp_fit step performed on MIRI data. """ input_file = self.get_data(self.test_dir, 'jw00001001001_01101_00001_MIRIMAGE_jump.fits') result = RampFitStep.call(input_file, save_opt=True, opt_name='rampfit1_opt_out.fits') output_file = result[0].save(path=result[0].meta.filename.replace('jump','rampfit')) int_output = result[1].save(path=result[1].meta.filename.replace('jump','rampfit_int')) result[0].close() result[1].close() outputs = [(output_file, 'jw00001001001_01101_00001_MIRIMAGE_ramp_fit.fits'), (int_output, 'jw00001001001_01101_00001_MIRIMAGE_int.fits'), ('rampfit1_opt_out_fitopt.fits', 'jw00001001001_01101_00001_MIRIMAGE_opt.fits') ] self.compare_outputs(outputs) def test_ramp_fit_miri2(self): """ Regression test of ramp_fit step performed on MIRI data. """ input_file = self.get_data(self.test_dir, 'jw80600012001_02101_00003_mirimage_jump.fits') result = RampFitStep.call(input_file, save_opt=True, opt_name='rampfit2_opt_out.fits') output_file = result[0].save(path=result[0].meta.filename.replace('jump','rampfit')) int_output = result[1].save(path=result[1].meta.filename.replace('jump','rampfit_int')) result[0].close() result[1].close() outputs = [(output_file, 'jw80600012001_02101_00003_mirimage_ramp.fits'), (int_output, 'jw80600012001_02101_00003_mirimage_int.fits'), ('rampfit2_opt_out_fitopt.fits', 'jw80600012001_02101_00003_mirimage_opt.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRICube(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_cube_build', 'truth'] test_dir = 'test_cube_build' rtol = 0.000001 def test_cubebuild_miri(self): """ Regression test of cube_build performed on MIRI MRS data. """ input_file = self.get_data(self.test_dir, 'jw10001001001_01101_00001_mirifushort_cal.fits') input_model = datamodels.IFUImageModel(input_file) CubeBuildStep.call(input_model, output_type='multi', save_results=True) outputs = [('jw10001001001_01101_00001_mirifushort_s3d.fits', 'jw10001001001_01101_00001_mirifushort_s3d_ref.fits', ['primary','sci','err','dq','wmap']) ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRILinearity(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_linearity','truth'] test_dir ='test_linearity' def test_linearity_miri3(self): """ Regression test of linearity step performed on MIRI data. """ input_file = self.get_data(self.test_dir, 'jw00001001001_01109_00001_MIRIMAGE_dark_current.fits') # get supplemental input override_file = self.get_data(self.test_dir, "lin_nan_flag_miri.fits") # run calibration step result = LinearityStep.call(input_file, override_linearity=override_file) output_file = result.meta.filename result.save(output_file) result.close() outputs = [(output_file, 'jw00001001001_01109_00001_MIRIMAGE_linearity.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRIWCSFixed(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_wcs','fixed','truth'] test_dir = os.path.join('test_wcs','fixed') def test_miri_fixed_slit_wcs(self): """ Regression test of creating a WCS object and doing pixel to sky transformation. """ input_file = self.get_data(self.test_dir, 'jw00035001001_01101_00001_mirimage_rate.fits') result = AssignWcsStep.call(input_file, save_results=True) cwd = os.path.abspath('.') os.makedirs('truth', exist_ok=True) os.chdir('truth') truth_file = self.get_data(*self.ref_loc, 'jw00035001001_01101_00001_mirimage_assign_wcs.fits') os.chdir(cwd) truth = ImageModel(truth_file) x, y = grid_from_bounding_box(result.meta.wcs.bounding_box) ra, dec, lam = result.meta.wcs(x, y) raref, decref, lamref = truth.meta.wcs(x, y) assert_allclose(ra, raref) assert_allclose(dec, decref) assert_allclose(lam, lamref) @pytest.mark.bigdata class TestMIRIWCSIFU(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_wcs', 'ifu', 'truth'] test_dir = os.path.join('test_wcs', 'ifu') def test_miri_ifu_wcs(self): """ Regression test of creating a WCS object and doing pixel to sky transformation. """ input_file = self.get_data(self.test_dir, 'jw00024001001_01101_00001_MIRIFUSHORT_uncal_MiriSloperPipeline.fits') result = AssignWcsStep.call(input_file, save_results=True) # Get the region file region = RegionsModel(crds_client.get_reference_file(result, 'regions')) # Choose the same plane as in the miri.py file (hardcoded for now). regions = region.regions[7, :, :] # inputs x, y = grid_from_bounding_box(result.meta.wcs.bounding_box) # Get indices where pixels == 0. These should be NaNs in the output. ind_zeros = regions == 0 cwd = os.path.abspath('.') os.makedirs('truth', exist_ok=True) os.chdir('truth') truth_file = self.get_data(*self.ref_loc, 'jw00024001001_01101_00001_MIRIFUSHORT_assign_wcs.fits') os.chdir(cwd) truth = ImageModel(truth_file) ra, dec, lam = result.meta.wcs(x, y) raref, decref, lamref = truth.meta.wcs(x, y) assert_allclose(ra, raref, equal_nan=True) assert_allclose(dec, decref, equal_nan=True) assert_allclose(lam, lamref, equal_nan=True) # Test that we got NaNs at ind_zero assert(np.isnan(ra).nonzero()[0] == ind_zeros.nonzero()[0]).all() assert(np.isnan(ra).nonzero()[1] == ind_zeros.nonzero()[1]).all() # Test the inverse transform x1, y1 = result.meta.wcs.backward_transform(ra, dec, lam) assert(np.isnan(x1).nonzero()[0] == ind_zeros.nonzero()[0]).all() assert (np.isnan(x1).nonzero()[1] == ind_zeros.nonzero()[1]).all() # Also run a smoke test with values outside the region. dec[100][200] = -80 ra[100][200] = 7 lam[100][200] = 15 x2, y2 = result.meta.wcs.backward_transform(ra, dec, lam) assert np.isnan(x2[100][200]) assert np.isnan(x2[100][200]) @pytest.mark.bigdata class TestMIRIWCSImage(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_wcs', 'image', 'truth'] test_dir = os.path.join('test_wcs', 'image') def test_miri_image_wcs(self): """ Regression test of creating a WCS object and doing pixel to sky transformation. """ input_file = self.get_data(self.test_dir, "jw00001001001_01101_00001_MIRIMAGE_ramp_fit.fits") result = AssignWcsStep.call(input_file, save_results=True) cwd = os.path.abspath('.') os.makedirs('truth', exist_ok=True) os.chdir('truth') truth_file = self.get_data(*self.ref_loc, "jw00001001001_01101_00001_MIRIMAGE_assign_wcs.fits") os.chdir(cwd) truth = ImageModel(truth_file) x, y = grid_from_bounding_box(result.meta.wcs.bounding_box) ra, dec = result.meta.wcs(x, y) raref, decref = truth.meta.wcs(x, y) assert_allclose(ra, raref) assert_allclose(dec, decref) @pytest.mark.bigdata class TestMIRIWCSSlitless(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_wcs', 'slitless', 'truth'] test_dir = os.path.join('test_wcs', 'slitless') def test_miri_slitless_wcs(self): """ Regression test of creating a WCS object and doing pixel to sky transformation. """ input_file = self.get_data(self.test_dir, "jw80600012001_02101_00003_mirimage_rateints.fits") result = AssignWcsStep.call(input_file, save_results=True) cwd = os.path.abspath('.') os.makedirs('truth', exist_ok=True) os.chdir('truth') truth_file = self.get_data(*self.ref_loc, "jw80600012001_02101_00003_mirimage_assignwcsstep.fits") os.chdir(cwd) truth = CubeModel(truth_file) x, y = grid_from_bounding_box(result.meta.wcs.bounding_box) ra, dec, lam = result.meta.wcs(x, y) raref, decref, lamref = truth.meta.wcs(x, y) assert_allclose(ra, raref) assert_allclose(dec, decref) assert_allclose(lam, lamref) @pytest.mark.bigdata class TestMIRISetPointing(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_pointing', 'truth'] test_dir = 'test_pointing' rtol = 0.000001 def test_miri_setpointing(self): """ Regression test of the set_telescope_pointing script on a level-1b MIRI file. """ # Copy original version of file to test file, which will get overwritten by test input_file = self.get_data(self.test_dir, 'jw80600010001_02101_00001_mirimage_uncal_orig.fits') # Get SIAF PRD database file siaf_prd_loc = ['jwst-pipeline', self.env, 'common', 'prd.db'] siaf_path = get_bigdata(*siaf_prd_loc) add_wcs(input_file, allow_default=True, siaf_path=siaf_path) outputs = [(input_file, 'jw80600010001_02101_00001_mirimage_uncal_ref.fits')] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRIMasterBackgroundLRS(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_masterbackground', 'lrs', 'truth'] test_dir = ['test_masterbackground', 'lrs'] rtol = 0.000001 def test_miri_lrs_masterbg_user(self): """ Regression test of masterbackgound subtraction with lrs, with user provided 1-D background """ # input file has the background added input_file = self.get_data(*self.test_dir, 'miri_lrs_sci+bkg_cal.fits') # user provided 1-D background user_background = self.get_data(*self.test_dir, 'miri_lrs_bkg_x1d.fits') result = MasterBackgroundStep.call(input_file, user_background=user_background, save_results=True) # Compare result (background subtracted image) to science image with no # background. Subtract these images, smooth the subtracted image and # the mean should be close to zero. input_sci_cal_file = self.get_data(*self.test_dir, 'miri_lrs_sci_cal.fits') input_sci = datamodels.open(input_sci_cal_file) # find the LRS region bb = result.meta.wcs.bounding_box x, y = grid_from_bounding_box(bb) result_lrs_region = result.data[y.astype(int), x.astype(int)] sci_lrs_region = input_sci.data[y.astype(int), x.astype(int)] # do a 5 sigma clip on the science image sci_mean = np.nanmean(sci_lrs_region) sci_std = np.nanstd(sci_lrs_region) upper = sci_mean + sci_std*5.0 lower = sci_mean - sci_std*5.0 mask_clean = np.logical_and(sci_lrs_region < upper, sci_lrs_region > lower) sub = result_lrs_region - sci_lrs_region mean_sub = np.absolute(np.mean(sub[mask_clean])) atol = 0.1 rtol = 0.001 assert_allclose(mean_sub, 0, atol=atol, rtol=rtol) # Test 3 Compare background subtracted science data (results) # to a truth file. truth_file = self.get_data(*self.ref_loc, 'miri_lrs_sci+bkg_masterbackgroundstep.fits') result_file = result.meta.filename outputs = [(result_file, truth_file)] self.compare_outputs(outputs) result.close() input_sci.close() @pytest.mark.bigdata class TestMIRIMasterBackgroundMRSDedicated(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_masterbackground', 'mrs', 'dedicated', 'truth'] test_dir = ['test_masterbackground', 'mrs', 'dedicated'] rtol = 0.000001 def test_miri_masterbg_mrs_dedicated(self): """Run masterbackground step on MIRI MRS association""" asn_file = self.get_data(*self.test_dir, 'miri_mrs_mbkg_0304_spec3_asn.json') for file in raw_from_asn(asn_file): self.get_data(*self.test_dir, file) collect_pipeline_cfgs('./config') result = MasterBackgroundStep.call( asn_file, config_file='config/master_background.cfg', save_background=True, save_results=True, ) # test 1 # loop over the background subtracted data and compare to truth files # check that the cal_step master_background ran to complete for model in result: assert model.meta.cal_step.master_background == 'COMPLETE' truth_file = self.get_data(*self.ref_loc, model.meta.filename) outputs = [(model.meta.filename, truth_file)] self.compare_outputs(outputs) # test 2 # compare the master background combined file to truth file master_combined_bkg_file = 'MIRI_MRS_seq1_MIRIFULONG_34LONGexp1_bkg_o002_masterbg.fits' truth_background = self.get_data(*self.ref_loc, master_combined_bkg_file) outputs = [(master_combined_bkg_file, truth_background)] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRIMasterBackgroundMRSNodded(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_masterbackground', 'mrs', 'nodded', 'truth'] test_dir = ['test_masterbackground', 'mrs', 'nodded'] rtol = 0.000001 def test_miri_masterbg_mrs_nodded(self): """Run masterbackground step on MIRI MRS association""" asn_file = self.get_data(*self.test_dir, 'miri_mrs_mbkg_spec3_asn.json') for file in raw_from_asn(asn_file): self.get_data(*self.test_dir, file) collect_pipeline_cfgs('./config') result = MasterBackgroundStep.call( asn_file, config_file='config/master_background.cfg', save_background=True, save_results=True, ) # test 1 # loop over the background subtracted data and compare to truth files # check that the cal_step master_background ran to complete for model in result: assert model.meta.cal_step.master_background == 'COMPLETE' truth_file = self.get_data(*self.ref_loc, model.meta.filename) outputs = [(model.meta.filename, truth_file)] self.compare_outputs(outputs) # test 2 # compare the master background combined file to truth file master_combined_bkg_file = 'MIRI_MRS_nod_seq1_MIRIFUSHORT_12SHORTexp1_o001_masterbg.fits' truth_background = self.get_data(*self.ref_loc, master_combined_bkg_file) outputs = [(master_combined_bkg_file, truth_background)] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRIMasterBackgroundLRSNodded(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_masterbackground', 'lrs', 'nodded', 'truth'] test_dir = ['test_masterbackground', 'lrs', 'nodded'] rtol = 0.000001 def test_miri_masterbg_lrs_nodded(self): """Run masterbackground step on MIRI LRS association""" asn_file = self.get_data(*self.test_dir, 'miri_lrs_mbkg_nodded_spec3_asn.json') for file in raw_from_asn(asn_file): self.get_data(*self.test_dir, file) collect_pipeline_cfgs('./config') result = MasterBackgroundStep.call( asn_file, config_file='config/master_background.cfg', save_background=True, save_results=True, ) # test 1 # loop over the background subtracted data and compare to truth files for model in result: assert model.meta.cal_step.master_background == 'COMPLETE' truth_file = self.get_data(*self.ref_loc, model.meta.filename) outputs = [(model.meta.filename, truth_file)] self.compare_outputs(outputs) # test 2 # compare the master background combined file to truth file master_combined_bkg_file = 'MIRI_LRS_nod_seq1_MIRIMAGE_P750Lexp1_o002_masterbg.fits' truth_background = self.get_data(*self.ref_loc, master_combined_bkg_file) outputs = [(master_combined_bkg_file, truth_background)] self.compare_outputs(outputs) @pytest.mark.bigdata class TestMIRIMasterBackgroundLRSDedicated(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_masterbackground', 'lrs', 'dedicated', 'truth'] test_dir = ['test_masterbackground', 'lrs', 'dedicated'] rtol = 0.000001 def test_miri_masterbg_lrs_dedicated(self): """Run masterbackground step on MIRI LRS association""" asn_file = self.get_data(*self.test_dir, 'miri_lrs_mbkg_dedicated_spec3_asn.json') for file in raw_from_asn(asn_file): self.get_data(*self.test_dir, file) collect_pipeline_cfgs('./config') result = MasterBackgroundStep.call( asn_file, config_file='config/master_background.cfg', save_background=True, save_results=True, ) # test 1 # loop over the background subtracted data and compare to truth files for model in result: assert model.meta.cal_step.master_background == 'COMPLETE' truth_file = self.get_data(*self.ref_loc, model.meta.filename) outputs = [(model.meta.filename, truth_file)] self.compare_outputs(outputs) # test 2 # compare the master background combined file to truth file master_combined_bkg_file = 'MIRI_LRS_seq1_MIRIMAGE_P750Lexp1_o001_masterbg.fits' truth_background = self.get_data(*self.ref_loc, master_combined_bkg_file) outputs = [(master_combined_bkg_file, truth_background)] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,480
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_wfs_combine.py
"""Test wfs_combine""" from glob import glob import os.path as op import pytest from jwst.tests.base_classes import BaseJWSTTest from jwst.associations import load_asn from jwst.associations.lib.rules_level3_base import format_product from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe.step import Step @pytest.mark.bigdata class TestWFSImage3Pipeline(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_wfs_combine', 'truth'] test_dir = 'test_wfs_combine' def test_asn_naming(self): """Test a full run""" # Get the data collect_pipeline_cfgs('cfgs') asn_path = self.get_data( self.test_dir, 'wfs_3sets_asn.json' ) with open(asn_path) as fh: asn = load_asn(fh) for product in asn['products']: for member in product['members']: self.get_data( self.test_dir, member['expname'] ) input_files = glob('*') # Run the step. args = [ op.join('cfgs', 'calwebb_wfs-image3.cfg'), asn_path ] Step.from_cmdline(args) # Test. output_files = glob('*') for input_file in input_files: output_files.remove(input_file) print('output_files = {}'.format(output_files)) for product in asn['products']: prod_name = product['name'] prod_name = format_product(prod_name, suffix='wfscmb') prod_name += '.fits' assert prod_name in output_files output_files.remove(prod_name) # There should be no more files assert len(output_files) == 0
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,481
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/niriss/test_niriss_steps.py
import pytest from jwst.tests.base_classes import BaseJWSTTestSteps from jwst.tests.base_classes import pytest_generate_tests # noqa: F401 from jwst.ami import AmiAnalyzeStep from jwst.refpix import RefPixStep from jwst.dark_current import DarkCurrentStep from jwst.dq_init import DQInitStep from jwst.flatfield import FlatFieldStep from jwst.jump import JumpStep from jwst.linearity import LinearityStep from jwst.saturation import SaturationStep from jwst.pathloss import PathLossStep # Parameterized regression tests for NIRISS processing # All tests in this set run with 1 input file and # only generate 1 output for comparison. # @pytest.mark.bigdata class TestNIRISSSteps(BaseJWSTTestSteps): input_loc = 'niriss' params = {'test_steps': [dict(input='ami_analyze_input_16.fits', test_dir='test_ami_analyze', step_class=AmiAnalyzeStep, step_pars=dict(oversample=3, rotation=1.49), output_truth=('ami_analyze_ref_output_16.fits', dict(rtol = 0.00001)), output_hdus=['primary','fit','resid','closure_amp', 'closure_pha','fringe_amp','fringe_pha', 'pupil_pha','solns'], id='ami_analyze_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_dq_init.fits', test_dir='test_bias_drift', step_class=RefPixStep, step_pars=dict(odd_even_columns=True, use_side_ref_pixels=False, side_smoothing_length=10, side_gain=1.0), output_truth='jw00034001001_01101_00001_NIRISS_bias_drift.fits', output_hdus=[], id='refpix_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_saturation.fits', test_dir='test_dark_step', step_class=DarkCurrentStep, step_pars=dict(), output_truth='jw00034001001_01101_00001_NIRISS_dark_current.fits', output_hdus=[], id='dark_current_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_uncal.fits', test_dir='test_dq_init', step_class=DQInitStep, step_pars=dict(), output_truth='jw00034001001_01101_00001_NIRISS_dq_init.fits', output_hdus=[], id='dq_init_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_ramp_fit.fits', test_dir='test_flat_field', step_class=FlatFieldStep, step_pars=dict(), output_truth='jw00034001001_01101_00001_NIRISS_flat_field.fits', output_hdus=[], id='flat_field_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_linearity.fits', test_dir='test_jump', step_class=JumpStep, step_pars=dict(rejection_threshold=20.0), output_truth='jw00034001001_01101_00001_NIRISS_jump.fits', output_hdus=[], id='jump_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_dark_current.fits', test_dir='test_linearity', step_class=LinearityStep, step_pars=dict(), output_truth='jw00034001001_01101_00001_NIRISS_linearity.fits', output_hdus=[], id='linearity_niriss' ), dict(input='jw00034001001_01101_00001_NIRISS_bias_drift.fits', test_dir='test_saturation', step_class=SaturationStep, step_pars=dict(), output_truth='jw00034001001_01101_00001_NIRISS_saturation.fits', output_hdus=[], id='saturation_niriss' ), dict(input='soss_2AB_results_int_assign_wcs.fits', test_dir='test_pathloss', step_class=PathLossStep, step_pars=dict(), output_truth='soss_2AB_results_int_pathloss.fits', output_hdus=[], id='pathloss_niriss' ), ] }
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,482
mperrin/jwst
refs/heads/master
/jwst/saturation/saturation.py
# # Module for 2d saturation # import logging from ..datamodels import dqflags from ..lib import reffile_utils from ..lib import pipe_utils from . import x_irs2 import numpy as np log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) HUGE_NUM = 100000. def do_correction(input_model, ref_model): """ Short Summary ------------- Execute all tasks for saturation, including using a saturation reference file. Parameters ---------- input_model: data model object The input science data to be corrected ref_model: data model object Saturation reference file mode object Returns ------- output_model: data model object object having GROUPDQ array saturation flags set """ ramparr = input_model.data # Was IRS2 readout used? is_irs2_format = pipe_utils.is_irs2(input_model) if is_irs2_format: irs2_mask = x_irs2.make_mask(input_model) # Create the output model as a copy of the input output_model = input_model.copy() groupdq = output_model.groupdq # Extract subarray from reference file, if necessary if reffile_utils.ref_matches_sci(input_model, ref_model): satmask = ref_model.data dqmask = ref_model.dq else: log.info('Extracting reference file subarray to match science data') ref_sub_model = reffile_utils.get_subarray_model(input_model, ref_model) satmask = ref_sub_model.data.copy() dqmask = ref_sub_model.dq.copy() ref_sub_model.close() # For pixels flagged in reference file as NO_SAT_CHECK, set the dq mask # and saturation mask wh_sat = np.bitwise_and(dqmask, dqflags.pixel['NO_SAT_CHECK']) dqmask[wh_sat == dqflags.pixel['NO_SAT_CHECK']] = dqflags.pixel['NO_SAT_CHECK'] satmask[wh_sat == dqflags.pixel['NO_SAT_CHECK']] = HUGE_NUM # Correct saturation values for NaNs in the ref file correct_for_NaN(satmask, dqmask) dq_flag = dqflags.group['SATURATED'] nints = ramparr.shape[0] ngroups = ramparr.shape[1] detector = input_model.meta.instrument.detector flagarray = np.zeros(ramparr.shape[-2:], dtype=groupdq.dtype) for ints in range(nints): for plane in range(ngroups): # Update the 4D groupdq array with the saturation flag. The # flag is set in the current plane and all following planes. if is_irs2_format: sci_temp = x_irs2.from_irs2(ramparr[ints, plane, :, :], irs2_mask, detector) flag_temp = np.where(sci_temp >= satmask, dq_flag, 0) # Copy flag_temp into flagarray. x_irs2.to_irs2(flagarray, flag_temp, irs2_mask, detector) else: flagarray[:, :] = np.where(ramparr[ints, plane, :, :] >= satmask, dq_flag, 0) np.bitwise_or(groupdq[ints, plane:, :, :], flagarray, groupdq[ints, plane:, :, :]) output_model.groupdq = groupdq if is_irs2_format: pixeldq_temp = x_irs2.from_irs2(output_model.pixeldq, irs2_mask, detector) pixeldq_temp = np.bitwise_or(pixeldq_temp, dqmask) x_irs2.to_irs2(output_model.pixeldq, pixeldq_temp, irs2_mask, detector) else: output_model.pixeldq = np.bitwise_or(output_model.pixeldq, dqmask) return output_model def correct_for_NaN(satmask, dqmask): """ Short Summary ------------- If there are NaNs in the saturation values in the reference file, reset them to a very high value such that the comparison never results in a positive (saturated) result for the associated pixels in the science data. Also reset the associated dqmask values to indicate that, effectively, no saturation check will be done for those pixels. Parameters ---------- satmask: 2-d array Subarray of saturation thresholds, from the saturation reference file. This may be modified in-place. dqmask: ndarray, same shape as `satmask` The DQ array from the saturation reference file, used to update the PIXELDQ array in the output. This may be modified in-place. """ # If there are NaNs as the saturation values, update those values # to ensure there will not be saturation. wh_nan = np.isnan(satmask) if np.any(wh_nan): satmask[wh_nan] = HUGE_NUM dqmask[wh_nan] |= dqflags.pixel['NO_SAT_CHECK'] log.info("Unflagged pixels having saturation values set to NaN were" " detected in the ref file; for those affected pixels no" " saturation check will be made.")
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,483
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/associations/conftest.py
"""Pytest configurations""" import pytest from jwst.tests_nightly.general.associations.sdp_pools_source import SDPPoolsSource # Add option to specify a single pool name def pytest_addoption(parser): parser.addoption( '--sdp-pool', metavar='sdp_pool', default=None, help='SDP test pool to run. Specify the name only, not extension or path' ) parser.addoption( '--standard-pool', metavar='standard_pool', default=None, help='Standard test pool to run. Specify the name only, not extension or path' ) @pytest.fixture def sdp_pool(request): """Retrieve a specific SDP pool to test""" return request.config.getoption('--sdp-pool') @pytest.fixture def standard_pool(request): """Retrieve a specific standard pool to test""" return request.config.getoption('--standard-pool') def pytest_generate_tests(metafunc): """Prefetch and parametrize a set of test pools""" if 'pool_path' in metafunc.fixturenames: SDPPoolsSource.inputs_root = metafunc.config.getini('inputs_root')[0] SDPPoolsSource.results_root = metafunc.config.getini('results_root')[0] SDPPoolsSource.env = metafunc.config.getoption('env') pools = SDPPoolsSource() try: pool_paths = pools.pool_paths except Exception: pool_paths = [] metafunc.parametrize('pool_path', pool_paths)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,484
mperrin/jwst
refs/heads/master
/jwst/master_background/nirspec_corrections.py
import logging log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) def correct_nrs_ifu_bkg(input): """Apply point source vs. uniform source pathloss adjustments to a NIRSpec IFU 2D master background array. Parameters ---------- input : `~jwst.datamodels.IFUImageModel` The input background data. Returns ------- input : `~jwst.datamodels.IFUIMAGEModel` An updated (in place) version of the input with the data replaced by the corrected 2D background. """ log.info('Applying point source pathloss updates to IFU background') # Try to load the appropriate pathloss correction arrays try: pl_point = input.getarray_noinit('pathloss_point') except AttributeError: log.warning('Pathloss_point array not found in input') log.warning('Skipping pathloss background updates') return input try: pl_uniform = input.getarray_noinit('pathloss_uniform') except AttributeError: log.warning('Pathloss_uniform array not found in input') log.warning('Skipping pathloss background updates') return input # Apply the corrections input.data *= (pl_point / pl_uniform) return input
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,485
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_tso3.py
import pytest from jwst.pipeline import Tso3Pipeline from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestTso3Pipeline(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_caltso3', 'truth'] test_dir = 'test_caltso3' def test_tso3_pipeline_nrc1(self): """Regression test of calwebb_tso3 pipeline on NIRCam simulated data. Default imaging mode outlier_detection will be tested here. """ asn_file = self.get_data(self.test_dir, "jw93065-a3001_20170511t111213_tso3_001_asn.json") for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) step = Tso3Pipeline() step.scale_detection = False step.outlier_detection.weight_type = 'exptime' step.outlier_detection.pixfrac = 1.0 step.outlier_detection.kernel = 'square' step.outlier_detection.fillval = 'INDEF' step.outlier_detection.nlow = 0 step.outlier_detection.nhigh = 0 step.outlier_detection.maskpt = 0.7 step.outlier_detection.grow = 1 step.outlier_detection.snr = '4.0 3.0' step.outlier_detection.scale = '0.5 0.4' step.outlier_detection.backg = 0.0 step.outlier_detection.save_intermediate_results = False step.outlier_detection.resample_data = False step.outlier_detection.good_bits = 4 step.extract_1d.smoothing_length = 0 step.extract_1d.bkg_order = 0 step.run(asn_file) outputs = [ # Compare level-2c product ('jw93065002001_02101_00001_nrca1_a3001_crfints.fits', 'jw93065002001_02101_00001_nrca1_a3001_crfints_ref.fits', ['primary', 'sci', 'dq', 'err']), # Compare level-3 product ('jw93065-a3001_t1_nircam_f150w-wlp8_phot.ecsv', 'jw93065-a3001_t1_nircam_f150w-wlp8_phot_ref.ecsv'), ] self.compare_outputs(outputs) def test_tso3_pipeline_nrc2(self): """Regression test of calwebb_tso3 pipeline on NIRCam simulated data. Scaled imaging mode outlier_detection will be tested here. """ asn_file = self.get_data(self.test_dir, "jw93065-a3002_20170511t111213_tso3_001_asn.json") for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) step = Tso3Pipeline() step.scale_detection = True step.outlier_detection.weight_type = 'exptime' step.outlier_detection.pixfrac = 1.0 step.outlier_detection.kernel = 'square' step.outlier_detection.fillval = 'INDEF' step.outlier_detection.nlow = 0 step.outlier_detection.nhigh = 0 step.outlier_detection.maskpt = 0.7 step.outlier_detection.grow = 1 step.outlier_detection.snr = '4.0 3.0' step.outlier_detection.scale = '0.5 0.4' step.outlier_detection.backg = 0.0 step.outlier_detection.save_intermediate_results = False step.outlier_detection.resample_data = False step.outlier_detection.good_bits = 4 step.extract_1d.smoothing_length = 0 step.extract_1d.bkg_order = 0 step.run(asn_file) outputs = [ # Compare level-2c product ('jw93065002002_02101_00001_nrca1_a3002_crfints.fits', 'jw93065002002_02101_00001_nrca1_a3002_crfints_ref.fits', ['primary', 'sci', 'dq', 'err']), # Compare level-3 product ('jw93065-a3002_t1_nircam_f150w-wlp8_phot.ecsv', 'jw93065-a3002_t1_nircam_f150w-wlp8_phot_ref.ecsv'), ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,486
mperrin/jwst
refs/heads/master
/jwst/coron/median_replace_img.py
"""Replace bad pixels with the median of the surrounding pixel and median fill the input images. """ import logging import numpy as np from jwst.datamodels import dqflags log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) def median_fill_value(input_array, input_dq_array, bsize, xc, yc): """ Arguments: ---------- input_array : ndarray Input array to filter. input_dq_array : ndarray Input data quality array bsize : scalar box size of the data to extract xc: scalar x position of the data extraction xc: scalar y position of the data extraction """ # set the half box size hbox = int(bsize/2) # Extract the region of interest for the data try: data_array = input_array[xc - hbox:xc + hbox, yc - hbox: yc + hbox] dq_array = input_dq_array[xc - hbox:xc + hbox, yc - hbox: yc + hbox] except IndexError: # If the box is outside the data return 0 log.warning('Box for median filter is outside the data.') return 0. filtered_array = data_array[dq_array != dqflags.pixel['DO_NOT_USE']] median_value = np.median(filtered_array) if np.isnan(median_value): # If the median fails return 0 log.warning('Median filter returned NaN setting value to 0.') median_value = 0. return median_value def median_replace_img(img_model, box_size): """ Routine to replace any bad pixels with the median value of the surrounding pixels. Arguments: ---------- input_array : image model Input array to filter. box_size : scalar box size for the median filter """ n_ints, _, _ = img_model.data.shape for nimage in range(n_ints): img_int = img_model.data[nimage] img_dq = img_model.dq[nimage] # check to see if any of the pixels are flagged if np.count_nonzero(img_dq == dqflags.pixel['DO_NOT_USE']) > 0: bad_locations = np.where(np.equal(img_dq, dqflags.pixel['DO_NOT_USE'])) # fill the bad pixel values with the median of the data in a box region for i_pos in range(len(bad_locations[0])): x_box_pos = bad_locations[0][i_pos] y_box_pos = bad_locations[1][i_pos] median_fill = median_fill_value(img_int, img_dq, box_size, x_box_pos, y_box_pos) img_int[x_box_pos, y_box_pos] = median_fill img_model.data[nimage] = img_int return img_model
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,487
mperrin/jwst
refs/heads/master
/jwst/regtest/test_nirspec_masterbackground.py
import pytest from astropy.io.fits.diff import FITSDiff from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step pytestmark = pytest.mark.bigdata def test_nirspec_fs_mbkg_user(rtdata, fitsdiff_default_kwargs): """Run a test for NIRSpec FS data with a user-supplied background file.""" # Get user-supplied background user_background = "v2_nrs_bkg_user_clean_x1d.fits" rtdata.get_data(f"nirspec/fs/{user_background}") # Get input data rtdata.get_data("nirspec/fs/nrs_sci+bkg_cal.fits") collect_pipeline_cfgs("config") args = ["config/master_background.cfg", rtdata.input, "--user_background", user_background] Step.from_cmdline(args) output = "nrs_sci+bkg_master_background.fits" rtdata.output = output # Get the truth file rtdata.get_truth(f"truth/test_nirspec_fs_mbkg_user/{output}") # Compare the results diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report() def test_nirspec_ifu_mbkg_user(rtdata, fitsdiff_default_kwargs): """Test NIRSpec IFU data with a user-supplied background file.""" # Get user-supplied background user_background = "prism_bkg_x1d.fits" rtdata.get_data(f"nirspec/ifu/{user_background}") # Get input data rtdata.get_data("nirspec/ifu/prism_sci_bkg_cal.fits") collect_pipeline_cfgs("config") args = ["config/master_background.cfg", rtdata.input, "--user_background", user_background] Step.from_cmdline(args) output = "prism_sci_bkg_master_background.fits" rtdata.output = output # Get the truth file rtdata.get_truth(f"truth/test_nirspec_ifu_mbkg_user/{output}") # Compare the results diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report() def test_nirspec_mos_mbkg_user(rtdata, fitsdiff_default_kwargs): """Test NIRSpec MOS data with a user-supplied background file.""" # Get user-supplied background user_background = "v2_nrs_mos_bkg_x1d.fits" rtdata.get_data(f"nirspec/mos/{user_background}") # Get input data rtdata.get_data("nirspec/mos/nrs_mos_sci+bkg_cal.fits") collect_pipeline_cfgs("config") args = ["config/master_background.cfg", rtdata.input, "--user_background", user_background] Step.from_cmdline(args) output = "nrs_mos_sci+bkg_master_background.fits" rtdata.output = output # Get the truth file rtdata.get_truth(f"truth/test_nirspec_mos_mbkg_user/{output}") # Compare the results diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report() @pytest.mark.parametrize( 'output_file', ['ifu_prism_source_on_NRS1_master_background.fits', 'ifu_prism_source_off_NRS1_o001_masterbg.fits'], ids=["on-source", "off-source"] ) def test_nirspec_ifu_mbkg_nod(rtdata, fitsdiff_default_kwargs, output_file): """Test NIRSpec IFU prism nodded data.""" # Get input data rtdata.get_asn("nirspec/ifu/nirspec_spec3_asn.json") collect_pipeline_cfgs("config") args = ["config/master_background.cfg", rtdata.input, "--save_background=True"] Step.from_cmdline(args) rtdata.output = output_file # Get the truth file rtdata.get_truth(f"truth/test_nirspec_ifu_mbkg_nod/{output_file}") # Compare the results diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report()
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,488
mperrin/jwst
refs/heads/master
/jwst/datamodels/properties.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst import copy import numpy as np from collections.abc import Mapping from astropy.io import fits from astropy.utils.compat.misc import override__dir__ from asdf import yamlutil from asdf.tags.core import ndarray from . import util from . import validate from . import schema as mschema import logging log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) log.addHandler(logging.NullHandler()) __all__ = ['ObjectNode', 'ListNode'] def _is_struct_array(val): return (isinstance(val, (np.ndarray, fits.FITS_rec)) and val.dtype.names is not None and val.dtype.fields is not None) def _is_struct_array_precursor(val): return isinstance(val, list) and isinstance(val[0], tuple) def _is_struct_array_schema(schema): return (isinstance(schema['datatype'], list) and any('name' in t for t in schema['datatype'])) def _cast(val, schema): val = _unmake_node(val) if val is None: return None if 'datatype' in schema: # Handle lazy array if isinstance(val, ndarray.NDArrayType): val = val._make_array() if (_is_struct_array_schema(schema) and len(val) and (_is_struct_array_precursor(val) or _is_struct_array(val))): # we are dealing with a structured array. Because we may # modify schema (to add shape), we make a deep copy of the # schema here: schema = copy.deepcopy(schema) for t, v in zip(schema['datatype'], val[0]): if not isinstance(t, Mapping): continue aval = np.asanyarray(v) shape = aval.shape val_ndim = len(shape) # make sure that if 'ndim' is specified for a field, # it matches the dimensionality of val's field: if 'ndim' in t and val_ndim != t['ndim']: raise ValueError( "Array has wrong number of dimensions. " "Expected {}, got {}".format(t['ndim'], val_ndim) ) if 'max_ndim' in t and val_ndim > t['max_ndim']: raise ValueError( "Array has wrong number of dimensions. " "Expected <= {}, got {}".format(t['max_ndim'], val_ndim) ) # if shape of a field's value is not specified in the schema, # add it to the schema based on the shape of the actual data: if 'shape' not in t: t['shape'] = shape dtype = ndarray.asdf_datatype_to_numpy_dtype(schema['datatype']) val = util.gentle_asarray(val, dtype) if dtype.fields is not None: val = _as_fitsrec(val) if 'ndim' in schema and len(val.shape) != schema['ndim']: raise ValueError( "Array has wrong number of dimensions. Expected {}, got {}" .format(schema['ndim'], len(val.shape))) if 'max_ndim' in schema and len(val.shape) > schema['max_ndim']: raise ValueError( "Array has wrong number of dimensions. Expected <= {}, got {}" .format(schema['max_ndim'], len(val.shape))) if isinstance(val, np.generic) and np.isscalar(val): val = val.item() return val def _as_fitsrec(val): """ Convert a numpy record into a fits record if it is not one already """ if isinstance(val, fits.FITS_rec): return val else: coldefs = fits.ColDefs(val) uint = any(c._pseudo_unsigned_ints for c in coldefs) fits_rec = fits.FITS_rec(val) fits_rec._coldefs = coldefs # FITS_rec needs to know if it should be operating in pseudo-unsigned-ints mode, # otherwise it won't properly convert integer columns with TZEROn before saving. fits_rec._uint = uint return fits_rec def _get_schema_type(schema): """ Create a list of types used by a schema and its subschemas when the subschemas are joined by combiners. Then return a type string if all the types are the same or 'mixed' if they differ """ def callback(subschema, path, combiner, types, recurse): if 'type' in subschema: types.append(subschema['type']) has_combiner = ('anyOf' in subschema.keys() or 'allOf' in subschema.keys()) return not has_combiner types = [] mschema.walk_schema(schema, callback, types) schema_type = None for a_type in types: if schema_type is None: schema_type = a_type elif schema_type != a_type: schema_type = 'mixed' break return schema_type def _make_default_array(attr, schema, ctx): dtype = schema.get('datatype') if dtype is not None: dtype = ndarray.asdf_datatype_to_numpy_dtype(dtype) ndim = schema.get('ndim', schema.get('max_ndim')) default = schema.get('default', None) primary_array_name = ctx.get_primary_array_name() if attr == primary_array_name: if ctx.shape is not None: shape = ctx.shape elif ndim is not None: shape = tuple([0] * ndim) else: shape = (0,) else: if dtype.names is not None: if ndim is None: shape = (0,) else: shape = tuple([0] * ndim) default = None else: has_primary_array_shape = False if primary_array_name is not None: primary_array = getattr(ctx, primary_array_name, None) has_primary_array_shape = primary_array is not None if has_primary_array_shape: if ndim is None: shape = primary_array.shape else: shape = primary_array.shape[-ndim:] elif ndim is None: shape = (0,) else: shape = tuple([0] * ndim) array = np.empty(shape, dtype=dtype) if default is not None: array[...] = default return array def _make_default(attr, schema, ctx): if 'max_ndim' in schema or 'ndim' in schema or 'datatype' in schema: return _make_default_array(attr, schema, ctx) elif 'default' in schema: return schema['default'] else: schema_type = _get_schema_type(schema) if schema_type == 'object': return {} elif schema_type == 'array': return [] else: return None def _make_node(attr, instance, schema, ctx): if isinstance(instance, dict): return ObjectNode(attr, instance, schema, ctx) elif isinstance(instance, list): return ListNode(attr, instance, schema, ctx) else: return instance def _unmake_node(obj): if isinstance(obj, Node): return obj.instance return obj def _get_schema_for_property(schema, attr): subschema = schema.get('properties', {}).get(attr, None) if subschema is not None: return subschema for combiner in ['allOf', 'anyOf']: for subschema in schema.get(combiner, []): subsubschema = _get_schema_for_property(subschema, attr) if subsubschema != {}: return subsubschema return {} def _get_schema_for_index(schema, i): items = schema.get('items', {}) if isinstance(items, list): if i >= len(items): return {} else: return items[i] else: return items def _find_property(schema, attr): subschema = _get_schema_for_property(schema, attr) if subschema == {}: find = False else: find = 'default' in subschema return find class Node(): def __init__(self, attr, instance, schema, ctx): self._name = attr self._instance = instance self._schema = schema self._ctx = ctx def _validate(self): instance = yamlutil.custom_tree_to_tagged_tree(self._instance, self._ctx._asdf) return validate.value_change(self._name, instance, self._schema, False, self._ctx._strict_validation) @property def instance(self): return self._instance class ObjectNode(Node): @override__dir__ def __dir__(self): return list(self._schema.get('properties', {}).keys()) def __eq__(self, other): if isinstance(other, ObjectNode): return self._instance == other._instance else: return self._instance == other def __getattr__(self, attr): from . import ndmodel if attr.startswith('_'): raise AttributeError('No attribute {0}'.format(attr)) schema = _get_schema_for_property(self._schema, attr) try: val = self._instance[attr] except KeyError: if schema == {}: raise AttributeError("No attribute '{0}'".format(attr)) val = _make_default(attr, schema, self._ctx) if val is not None: self._instance[attr] = val if isinstance(val, dict): # Meta is special cased to support NDData interface if attr == 'meta': node = ndmodel.MetaNode(attr, val, schema, self._ctx) else: node = ObjectNode(attr, val, schema, self._ctx) elif isinstance(val, list): node = ListNode(attr, val, schema, self._ctx) else: node = val return node def __setattr__(self, attr, val): if attr.startswith('_'): self.__dict__[attr] = val else: schema = _get_schema_for_property(self._schema, attr) if val is None: val = _make_default(attr, schema, self._ctx) val = _cast(val, schema) node = ObjectNode(attr, val, schema, self._ctx) if node._validate(): self._instance[attr] = val def __delattr__(self, attr): if attr.startswith('_'): del self.__dict__[attr] else: schema = _get_schema_for_property(self._schema, attr) if not validate.value_change(attr, None, schema, False, self._ctx._strict_validation): return try: del self._instance[attr] except KeyError: raise AttributeError( "Attribute '{0}' missing".format(attr)) def __iter__(self): return NodeIterator(self) def hasattr(self, attr): return attr in self._instance def items(self): # Return a (key, value) tuple for the node for key in self: val = self for field in key.split('.'): val = getattr(val, field) yield (key, val) class ListNode(Node): def __cast(self, other): if isinstance(other, ListNode): return other._instance return other def __repr__(self): return repr(self._instance) def __eq__(self, other): return self._instance == self.__cast(other) def __ne__(self, other): return self._instance != self.__cast(other) def __contains__(self, item): return item in self._instance def __len__(self): return len(self._instance) def __getitem__(self, i): schema = _get_schema_for_index(self._schema, i) return _make_node(self._name, self._instance[i], schema, self._ctx) def __setitem__(self, i, val): schema = _get_schema_for_index(self._schema, i) val = _cast(val, schema) node = ObjectNode(self._name, val, schema, self._ctx) if node._validate(): self._instance[i] = val def __delitem__(self, i): del self._instance[i] self._validate() def __getslice__(self, i, j): if isinstance(self._schema['items'], list): r = range(*(slice(i, j).indices(len(self._instance)))) schema_parts = [ _get_schema_for_index(self._schema, x) for x in r ] else: schema_parts = self._schema['items'] schema = {'type': 'array', 'items': schema_parts} return _make_node(self._name, self._instance[i:j], schema, self._ctx) def __setslice__(self, i, j, other): parts = _unmake_node(other) parts = [_cast(x, _get_schema_for_index(self._schema, k)) for (k, x) in enumerate(parts)] self._instance[i:j] = _unmake_node(other) self._validate() def __delslice__(self, i, j): del self._instance[i:j] self._validate() def append(self, item): schema = _get_schema_for_index(self._schema, len(self._instance)) item = _cast(item, schema) node = ObjectNode(self._name, item, schema, self._ctx) if node._validate(): self._instance.append(item) def insert(self, i, item): schema = _get_schema_for_index(self._schema, i) item = _cast(item, schema) node = ObjectNode(self._name, item, schema, self._ctx) if node._validate(): self._instance.insert(i, item) def pop(self, i=-1): schema = _get_schema_for_index(self._schema, 0) x = self._instance.pop(i) return _make_node(self._name, x, schema, self._ctx) def remove(self, item): self._instance.remove(item) def count(self, item): return self._instance.count(item) def index(self, item): return self._instance.index(item) def reverse(self): self._instance.reverse() def sort(self, *args, **kwargs): self._instance.sort(*args, **kwargs) def extend(self, other): for part in _unmake_node(other): self.append(part) def item(self, **kwargs): assert isinstance(self._schema['items'], dict) node = ObjectNode(self._name, kwargs, self._schema['items'], self._ctx) if not node._validate(): node = None return node class NodeIterator: """ An iterator for a node which flattens the hierachical structure """ def __init__(self, node): self.key_stack = [] self.iter_stack = [iter(node._instance.items())] def __iter__(self): return self def __next__(self): while self.iter_stack: try: key, val = next(self.iter_stack[-1]) except StopIteration: self.iter_stack.pop() if self.iter_stack: self.key_stack.pop() continue if isinstance(val, dict): self.key_stack.append(key) self.iter_stack.append(iter(val.items())) else: return '.'.join(self.key_stack + [key]) raise StopIteration def put_value(path, value, tree): """ Put a value at the given path into tree, replacing it if it is already present. Parameters ---------- path : list of str or int The path to the element. value : any The value to place tree : JSON object tree """ cursor = tree for i in range(len(path) - 1): part = path[i] if isinstance(part, int): while len(cursor) <= part: cursor.append({}) cursor = cursor[part] else: if isinstance(path[i + 1], int) or path[i + 1] == 'items': cursor = cursor.setdefault(part, []) else: cursor = cursor.setdefault(part, {}) if isinstance(path[-1], int): while len(cursor) <= path[-1]: cursor.append({}) cursor[path[-1]] = value def merge_tree(a, b): """ Merge elements from tree `b` into tree `a`. """ def recurse(a, b): if isinstance(b, dict): if not isinstance(a, dict): return copy.deepcopy(b) for key, val in b.items(): a[key] = recurse(a.get(key), val) return a return copy.deepcopy(b) recurse(a, b) return a
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,489
mperrin/jwst
refs/heads/master
/jwst/datamodels/util.py
""" Various utility functions and data types """ import sys import warnings import os from os.path import basename import numpy as np from astropy.io import fits from ..lib import s3_utils import logging log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) log.addHandler(logging.NullHandler()) class NoTypeWarning(Warning): pass def open(init=None, memmap=False, **kwargs): """ Creates a DataModel from a number of different types Parameters ---------- init : shape tuple, file path, file object, astropy.io.fits.HDUList, numpy array, dict, None - None: A default data model with no shape - shape tuple: Initialize with empty data of the given shape - file path: Initialize from the given file (FITS , JSON or ASDF) - readable file object: Initialize from the given file object - astropy.io.fits.HDUList: Initialize from the given `~astropy.io.fits.HDUList` - A numpy array: A new model with the data array initialized to what was passed in. - dict: The object model tree for the data model memmap : bool Turn memmap of FITS file on or off. (default: False). Ignored for ASDF files. kwargs : dict Additional keyword arguments passed to lower level functions. These arguments are generally file format-specific. Arguments of note are: - FITS skip_fits_update - bool or None `True` to skip updating the ASDF tree from the FITS headers, if possible. If `None`, value will be taken from the environmental SKIP_FITS_UPDATE. Otherwise, the default value is `True`. Returns ------- model : DataModel instance """ from . import model_base from . import filetype # Initialize variables used to select model class hdulist = {} shape = () file_name = None file_to_close = None # Get special cases for opening a model out of the way # all special cases return a model if they match if init is None: return model_base.DataModel(None) elif isinstance(init, model_base.DataModel): # Copy the object so it knows not to close here return init.__class__(init) elif isinstance(init, (str, bytes)) or hasattr(init, "read"): # If given a string, presume its a file path. # if it has a read method, assume a file descriptor if isinstance(init, bytes): init = init.decode(sys.getfilesystemencoding()) file_name = basename(init) file_type = filetype.check(init) if file_type == "fits": if s3_utils.is_s3_uri(init): hdulist = fits.open(s3_utils.get_object(init)) else: hdulist = fits.open(init, memmap=memmap) file_to_close = hdulist elif file_type == "asn": # Read the file as an association / model container from . import container return container.ModelContainer(init, **kwargs) elif file_type == "asdf": # Read the file as asdf, no need for a special class return model_base.DataModel(init, **kwargs) elif isinstance(init, tuple): for item in init: if not isinstance(item, int): raise ValueError("shape must be a tuple of ints") shape = init elif isinstance(init, np.ndarray): shape = init.shape elif isinstance(init, fits.HDUList): hdulist = init elif is_association(init) or isinstance(init, list): from . import container return container.ModelContainer(init, **kwargs) # If we have it, determine the shape from the science hdu if hdulist: # So we don't need to open the image twice init = hdulist info = init.fileinfo(0) if info is not None: file_name = info.get('filename') try: hdu = hdulist[('SCI', 1)] except (KeyError, NameError): shape = () else: if hasattr(hdu, 'shape'): shape = hdu.shape else: shape = () # First try to get the class name from the primary header new_class = _class_from_model_type(hdulist) has_model_type = new_class is not None # Special handling for ramp files for backwards compatibility if new_class is None: new_class = _class_from_ramp_type(hdulist, shape) # Or get the class from the reference file type and other header keywords if new_class is None: new_class = _class_from_reftype(hdulist, shape) # Or Get the class from the shape if new_class is None: new_class = _class_from_shape(hdulist, shape) # Throw an error if these attempts were unsuccessful if new_class is None: raise TypeError("Can't determine datamodel class from argument to open") # Log a message about how the model was opened if file_name: log.debug(f'Opening {file_name} as {new_class}') else: log.debug(f'Opening as {new_class}') # Actually open the model model = new_class(init, **kwargs) # Close the hdulist if we opened it if file_to_close is not None: model._files_to_close.append(file_to_close) if not has_model_type: class_name = new_class.__name__.split('.')[-1] if file_name: warnings.warn(f"model_type not found. Opening {file_name} as a {class_name}", NoTypeWarning) try: delattr(model.meta, 'model_type') except AttributeError: pass return model def _class_from_model_type(hdulist): """ Get the model type from the primary header, lookup to get class """ from . import _defined_models as defined_models if hdulist: primary = hdulist[0] model_type = primary.header.get('DATAMODL') if model_type is None: new_class = None else: new_class = defined_models.get(model_type) else: new_class = None return new_class def _class_from_ramp_type(hdulist, shape): """ Special check to see if file is ramp file """ if not hdulist: new_class = None else: if len(shape) == 4: try: hdulist['DQ'] except KeyError: from . import ramp new_class = ramp.RampModel else: new_class = None else: new_class = None return new_class def _class_from_reftype(hdulist, shape): """ Get the class name from the reftype and other header keywords """ if not hdulist: new_class = None else: primary = hdulist[0] reftype = primary.header.get('REFTYPE') if reftype is None: new_class = None else: from . import reference if len(shape) == 0: new_class = reference.ReferenceFileModel elif len(shape) == 2: new_class = reference.ReferenceImageModel elif len(shape) == 3: new_class = reference.ReferenceCubeModel elif len(shape) == 4: new_class = reference.ReferenceQuadModel else: new_class = None return new_class def _class_from_shape(hdulist, shape): """ Get the class name from the shape """ if len(shape) == 0: from . import model_base new_class = model_base.DataModel elif len(shape) == 4: from . import quad new_class = quad.QuadModel elif len(shape) == 3: from . import cube new_class = cube.CubeModel elif len(shape) == 2: try: hdulist[('SCI', 2)] except (KeyError, NameError): # It's an ImageModel from . import image new_class = image.ImageModel else: # It's a MultiSlitModel from . import multislit new_class = multislit.MultiSlitModel else: new_class = None return new_class def can_broadcast(a, b): """ Given two shapes, returns True if they are broadcastable. """ for i in range(1, min(len(a), len(b)) + 1): adim = a[-i] bdim = b[-i] if not (adim == 1 or bdim == 1 or adim == bdim): return False return True def to_camelcase(token): return ''.join(x.capitalize() for x in token.split('_-')) def is_association(asn_data): """ Test if an object is an association by checking for required fields """ if isinstance(asn_data, dict): if 'asn_id' in asn_data and 'asn_pool' in asn_data: return True return False def gentle_asarray(a, dtype): """ Performs an asarray that doesn't cause a copy if the byteorder is different. It also ignores column name differences -- the resulting array will have the column names from the given dtype. """ out_dtype = np.dtype(dtype) if isinstance(a, np.ndarray): in_dtype = a.dtype # Non-table array if in_dtype.fields is None and out_dtype.fields is None: if np.can_cast(in_dtype, out_dtype, 'equiv'): return a else: return np.asanyarray(a, dtype=out_dtype) elif in_dtype.fields is not None and out_dtype.fields is not None: # When a FITS file includes a pseudo-unsigned-int column, astropy will return # a FITS_rec with an incorrect table dtype. The following code rebuilds # in_dtype from the individual fields, which are correctly labeled with an # unsigned int dtype. # We can remove this once the issue is resolved in astropy: # https://github.com/astropy/astropy/issues/8862 if isinstance(a, fits.fitsrec.FITS_rec): new_in_dtype = [] updated = False for field_name in in_dtype.fields: table_dtype = in_dtype[field_name] field_dtype = a.field(field_name).dtype if np.issubdtype(table_dtype, np.signedinteger) and np.issubdtype(field_dtype, np.unsignedinteger): new_in_dtype.append((field_name, field_dtype)) updated = True else: new_in_dtype.append((field_name, table_dtype)) if updated: in_dtype = np.dtype(new_in_dtype) if in_dtype == out_dtype: return a in_names = {n.lower() for n in in_dtype.names} out_names = {n.lower() for n in out_dtype.names} if in_names == out_names: # Change the dtype name to match the fits record names # as the mismatch causes case insensitive access to fail out_dtype.names = in_dtype.names else: raise ValueError( "Column names don't match schema. " "Schema has {0}. Data has {1}".format( str(out_names.difference(in_names)), str(in_names.difference(out_names)))) new_dtype = [] for i in range(len(out_dtype.fields)): in_type = in_dtype[i] out_type = out_dtype[i] if in_type.subdtype is None: type_str = in_type.str else: type_str = in_type.subdtype[0].str if np.can_cast(in_type, out_type, 'equiv'): new_dtype.append( (out_dtype.names[i], type_str, in_type.shape)) else: return np.asanyarray(a, dtype=out_dtype) return a.view(dtype=np.dtype(new_dtype)) else: return np.asanyarray(a, dtype=out_dtype) else: try: a = np.asarray(a, dtype=out_dtype) except Exception: raise ValueError("Can't convert {0!s} to ndarray".format(type(a))) return a def get_short_doc(schema): title = schema.get('title', None) description = schema.get('description', None) if description is None: description = title or '' else: if title is not None: description = title + '\n\n' + description return description.partition('\n')[0] def ensure_ascii(s): if isinstance(s, bytes): s = s.decode('ascii') return s def create_history_entry(description, software=None): """ Create a HistoryEntry object. Parameters ---------- description : str Description of the change. software : dict or list of dict A description of the software used. It should not include asdf itself, as that is automatically notated in the `asdf_library` entry. Each dict must have the following keys: ``name``: The name of the software ``author``: The author or institution that produced the software ``homepage``: A URI to the homepage of the software ``version``: The version of the software Examples -------- >>> soft = {'name': 'jwreftools', 'author': 'STSCI', \ 'homepage': 'https://github.com/spacetelescope/jwreftools', 'version': "0.7"} >>> entry = create_history_entry(description="HISTORY of this file", software=soft) """ from asdf.tags.core import Software, HistoryEntry import datetime if isinstance(software, list): software = [Software(x) for x in software] elif software is not None: software = Software(software) entry = HistoryEntry({ 'description': description, 'time': datetime.datetime.utcnow() }) if software is not None: entry['software'] = software return entry def get_envar_as_boolean(name, default=False): """Interpret an environmental as a boolean flag Truth is any numeric value that is not 0 or any of the following case-insensitive strings: ('true', 't', 'yes', 'y') Parameters ---------- name : str The name of the environmental variable to retrieve default : bool If the environmental variable cannot be accessed, use as the default. """ truths = ('true', 't', 'yes', 'y') falses = ('false', 'f', 'no', 'n') if name in os.environ: value = os.environ[name] try: value = bool(int(value)) except ValueError: value_lowcase = value.lower() if value_lowcase not in truths + falses: raise ValueError(f'Cannot convert value "{value}" to boolean unambiguously.') return value_lowcase in truths return value log.debug(f'Environmental "{name}" cannot be found. Using default value of "{default}".') return default
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,490
mperrin/jwst
refs/heads/master
/jwst/tests/test_velocity_aberration.py
""" Test script for set_velocity_aberration.py """ from numpy import isclose import os import sys sys.path.insert( 0, os.path.join(os.path.dirname(__file__), '../../scripts') ) import set_velocity_aberration as sva # noqa: E402 # Testing constants GOOD_VELOCITY = (100.0, 100.0, 100.0) GOOD_POS = (0., 0.) GOOD_SCALE_FACTOR = 1.000333731048419 GOOD_OFFSET_X = 0.00033356409519815205 GOOD_OFFSET_Y = 0.00033356409519815205 ZERO_VELOCITY = 0. ZERO_SCALE_FACTOR = 1.0 ZERO_OFFSET_X = 0. ZERO_OFFSET_Y = 0. def test_scale_factor_valid(): scale_factor = sva.aberration_scale( GOOD_VELOCITY[0], GOOD_VELOCITY[1], GOOD_VELOCITY[2], GOOD_POS[0], GOOD_POS[1] ) assert isclose(scale_factor, GOOD_SCALE_FACTOR) def test_scale_factor_zero_velocity(): scale_factor = sva.aberration_scale( ZERO_VELOCITY, ZERO_VELOCITY, ZERO_VELOCITY, GOOD_POS[0], GOOD_POS[1] ) assert isclose(scale_factor, ZERO_SCALE_FACTOR) def test_offset_valid(): delta_x, delta_y = sva.aberration_offset( GOOD_VELOCITY[0], GOOD_VELOCITY[1], GOOD_VELOCITY[2], GOOD_POS[0], GOOD_POS[1] ) assert isclose(delta_x, GOOD_OFFSET_X) assert isclose(delta_y, GOOD_OFFSET_Y) def test_offset_zero_velocity(): delta_x, delta_y = sva.aberration_offset( ZERO_VELOCITY, ZERO_VELOCITY, ZERO_VELOCITY, GOOD_POS[0], GOOD_POS[1] ) assert isclose(delta_x, ZERO_OFFSET_X) assert isclose(delta_y, ZERO_OFFSET_Y)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,491
mperrin/jwst
refs/heads/master
/jwst/datamodels/history.py
from asdf.tags.core import HistoryEntry def _iterable(values): if isinstance(values, str) or not hasattr(values, '__iter__'): values = (values,) return values class HistoryList: """ A list that coerces a new value into a HistoryEntry. Only a subset of the list interface is implemented. """ def __init__(self, asdf): self._context = asdf if len(self._context.get_history_entries()): self._entries = self._context.get_history_entries() else: self._context.add_history_entry("fake entry") self._entries = self._context.get_history_entries() self._entries.clear() def __len__(self): return len(self._entries) def __getitem__(self, key): return self._entries[key] def __setitem__(self, key, value): self.append(value) value = self._entries.pop() self._entries[key] = value def __delitem__(self, key): del self._entries[key] def __iter__(self): return iter(self._entries) def __repr__(self): return repr(self._entries) def __str__(self): return str(self._entries) def __eq__(self, other): if isinstance(other, HistoryList): other = other._entries else: other = _iterable(other) if len(self) != len(other): return False for self_entry, other_entry in zip(self._entries, other): if isinstance(other_entry, str): if self_entry.get('description') != other_entry: return False elif isinstance(other_entry, dict): for key in other_entry.keys(): if self_entry.get(key) != other_entry.get(key): return False return True def append(self, value): if isinstance(value, HistoryEntry): self._entries.append(value) else: self._context.add_history_entry(value) def clear(self): self._entries.clear() def extend(self, values): values = _iterable(values) for value in values: self.append(value)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,492
mperrin/jwst
refs/heads/master
/jwst/datamodels/level1b.py
from .model_base import DataModel __all__ = ['Level1bModel'] class Level1bModel(DataModel): """ A data model for raw 4D ramps level-1b products. Parameters __________ data : numpy uint16 array The science data zeroframe : numpy uint16 array Zeroframe array refout : numpy uint16 array Reference Output group : numpy table group parameters table int_times : numpy table table of times for each integration """ schema_url = "http://stsci.edu/schemas/jwst_datamodel/level1b.schema" def __init__(self, init=None, **kwargs): super(Level1bModel, self).__init__(init=init, **kwargs) # zeroframe is a lower dimensional array than # the science data. However, its dimensions are not # consecutive with data, so the default model # creates a wrongly shaped array. If data is given # use the appropriate dimensions. # # TODO: Hacky. Need solution which involves schema # specification and embedded in DataModel. #if 'zeroframe' not in self.instance and \ # 'data' in self.instance and \ # len(self.data.shape) == 4: # nints, ngroups, ny, nx = self.data.shape # self.zeroframe = np.zeros((nints, ny, nx))
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,493
mperrin/jwst
refs/heads/master
/jwst/resample/tests/test_resample_spec.py
import numpy as np from numpy.testing import assert_allclose from ...datamodels import ImageModel from jwst.assign_wcs import AssignWcsStep from jwst.extract_2d import Extract2dStep from jwst.resample import ResampleSpecStep from gwcs.wcstools import grid_from_bounding_box def test_spatial_transform_nirspec(): wcsinfo = { 'dec_ref': -0.00601415671349804, 'ra_ref': -0.02073605215697509, 'roll_ref': -0.0, 'v2_ref': -453.5134, 'v3_ref': -373.4826, 'v3yangle': 0.0, 'vparity': -1} instrument = { 'detector': 'NRS1', 'filter': 'CLEAR', 'grating': 'PRISM', 'name': 'NIRSPEC', 'gwa_tilt': 37.0610, 'gwa_xtilt': 0.0001, 'gwa_ytilt': 0.0001} subarray = { 'fastaxis': 1, 'name': 'SUBS200A1', 'slowaxis': 2, 'xsize': 72, 'xstart': 1, 'ysize': 416, 'ystart': 529} observation = { 'date': '2016-09-05', 'time': '8:59:37'} exposure = { 'duration': 11.805952, 'end_time': 58119.85416, 'exposure_time': 11.776, 'frame_time': 0.11776, 'group_time': 0.11776, 'groupgap': 0, 'integration_time': 11.776, 'nframes': 1, 'ngroups': 100, 'nints': 1, 'nresets_between_ints': 0, 'nsamples': 1, 'readpatt': 'NRSRAPID', 'sample_time': 10.0, 'start_time': 58119.8333, 'type': 'NRS_FIXEDSLIT', 'zero_frame': False} im = ImageModel() im.data = np.random.rand(2048, 2048) im.error = np.random.rand(2048, 2048) im.dq = np.random.rand(2048, 2048) im.meta.wcsinfo._instance.update(wcsinfo) im.meta.instrument._instance.update(instrument) im.meta.observation._instance.update(observation) im.meta.exposure._instance.update(exposure) im.meta.subarray._instance.update(subarray) im.meta.filename = 'test.fits' im = AssignWcsStep.call(im) im = Extract2dStep.call(im) im = ResampleSpecStep.call(im) for slit in im.slits: x, y =grid_from_bounding_box(slit.meta.wcs.bounding_box) ra, dec, lam = slit.meta.wcs(x, y) ra1 = np.where(ra < 0, 360 + ra, ra) assert_allclose(slit.meta.wcs.invert(ra, dec, lam), slit.meta.wcs.invert(ra1, dec, lam)) def test_spatial_transform_miri(): wcsinfo = { 'dec_ref': -0.00601415671349804, 'ra_ref': -0.02073605215697509, 'roll_ref': -0.0, 'v2_ref': -453.5134, 'v3_ref': -373.4826, 'v3yangle': 0.0, 'vparity': -1} instrument = { 'detector': 'MIRIMAGE', 'filter': 'P750L', 'name': 'MIRI'} observation = { 'date': '2019-01-01', 'time': '17:00:00'} subarray = { 'fastaxis': 1, 'name': 'SLITLESSPRISM', 'slowaxis': 2, 'xsize': 72, 'xstart': 1, 'ysize': 416, 'ystart': 529} exposure = { 'duration': 11.805952, 'end_time': 58119.85416, 'exposure_time': 11.776, 'frame_time': 0.11776, 'group_time': 0.11776, 'groupgap': 0, 'integration_time': 11.776, 'nframes': 1, 'ngroups': 100, 'nints': 1, 'nresets_between_ints': 0, 'nsamples': 1, 'readpatt': 'FAST', 'sample_time': 10.0, 'start_time': 58119.8333, 'type': 'MIR_LRS-SLITLESS', 'zero_frame': False} im = ImageModel() im.data = np.random.rand(416, 72) im.error = np.random.rand(416, 72) im.dq = np.random.rand(416, 72) im.meta.wcsinfo._instance.update(wcsinfo) im.meta.instrument._instance.update(instrument) im.meta.observation._instance.update(observation) im.meta.exposure._instance.update(exposure) im.meta.subarray._instance.update(subarray) out = AssignWcsStep.call(im) out = ResampleSpecStep.call(out) x, y =grid_from_bounding_box(out.meta.wcs.bounding_box) ra, dec, lam = out.meta.wcs(x, y) ra1 = np.where(ra < 0, 360 + ra, ra) assert_allclose(out.meta.wcs.invert(ra, dec, lam), out.meta.wcs.invert(ra1, dec, lam))
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,494
mperrin/jwst
refs/heads/master
/jwst/regtest/test_nirspec_image2.py
import pytest from astropy.io.fits.diff import FITSDiff from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step @pytest.mark.bigdata def test_nirspec_image2(_jail, rtdata, fitsdiff_default_kwargs): rtdata.get_data("nirspec/imaging/jw84600010001_02102_00001_nrs2_rate.fits") collect_pipeline_cfgs("config") args = ["config/calwebb_image2.cfg", rtdata.input] Step.from_cmdline(args) rtdata.output = "jw84600010001_02102_00001_nrs2_cal.fits" rtdata.get_truth("truth/test_nirspec_image2/jw84600010001_02102_00001_nrs2_cal.fits") diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report()
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,495
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py
"""Test calwebb_spec2 for NIRSpec MSA""" import os.path as op import pytest from jwst.tests.base_classes import BaseJWSTTest from jwst.associations import load_asn from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe.step import Step @pytest.mark.bigdata class TestSpec2NRSMSA(BaseJWSTTest): """Test various aspects of calibrating NIRSpec MSA mode""" input_loc = 'nirspec' ref_loc = ['test_datasets', 'msa', 'simulated-3nod', 'truth'] test_dir = ['test_datasets', 'msa', 'simulated-3nod'] def test_msa_missing(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits' ) collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file ] with pytest.raises(Exception): Step.from_cmdline(args) assert 'Missing MSA meta (MSAMETFL) file' in caplog.text def test_msa_missing_nofail(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits' ) collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file, '--fail_on_exception=false' ] Step.from_cmdline(args) assert 'Missing MSA meta (MSAMETFL) file' in caplog.text def test_msa_missing_skip(self, caplog): """Test MSA missing failure""" input_file = self.get_data( *self.test_dir, 'level2a_twoslit', 'F170LP-G235M_MOS_observation-6-c0e0_001_DN_NRS1_mod.fits' ) collect_pipeline_cfgs('cfgs') args = [ op.join('cfgs', 'calwebb_spec2.cfg'), input_file, '--steps.assign_wcs.skip=true' ] Step.from_cmdline(args) assert 'Aborting remaining processing for this exposure.' in caplog.text def test_run_msaflagging(self, caplog): """Test msa flagging operation""" # Retrieve the data. collect_pipeline_cfgs('cfgs') self.get_data( *self.test_dir, 'jw95065006001_0_msa_twoslit.fits' ) asn_path = self.get_data( *self.test_dir, 'mos_udf_g235m_twoslit_spec2_asn.json' ) with open(asn_path) as fp: asn = load_asn(fp) for product in asn['products']: for member in product['members']: self.get_data( *self.test_dir, 'level2a_twoslit', member['expname'] ) # Run step. args = [ op.join('cfgs', 'calwebb_spec2.cfg'), asn_path, '--steps.msa_flagging.skip=false' ] Step.from_cmdline(args) # Test. assert 'Step msa_flagging running with args' in caplog.text assert 'Step msa_flagging done' in caplog.text for product in asn['products']: prod_name = product['name'] + '_cal.fits' assert op.isfile(prod_name)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,496
mperrin/jwst
refs/heads/master
/jwst/jump/tests/test_detect_jumps.py
import numpy as np import pytest from jwst.datamodels import GainModel, ReadnoiseModel from jwst.datamodels import RampModel from jwst.jump.jump import detect_jumps import multiprocessing from jwst.datamodels import dqflags def test_nocrs_noflux(setup_inputs): """" All pixel values are zero. So slope should be zero """ model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=5) out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 4, True) assert (0 == np.max(out_model.groupdq)) def test_nocrs_noflux_badgain_pixel(setup_inputs): """" all pixel values are zero. So slope should be zero, pixel with bad gain should have pixel dq set to 'NO_GAIN_VALUE' and 'DO_NOT_USE' """ model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=5) gain.data[7, 7] = -10 #bad gain gain.data[17, 17] = np.nan # bad gain out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 4, True) assert(np.bitwise_and(out_model.pixeldq[7, 7], dqflags.pixel['NO_GAIN_VALUE'])) assert (np.bitwise_and(out_model.pixeldq[7, 7], dqflags.pixel['DO_NOT_USE'])) assert (np.bitwise_and(out_model.pixeldq[17, 17], dqflags.pixel['NO_GAIN_VALUE'])) assert (np.bitwise_and(out_model.pixeldq[17, 17], dqflags.pixel['DO_NOT_USE'])) def test_nocrs_noflux_subarray(setup_inputs): """" All pixel values are zero. This shows that the subarray reference files get extracted from the full frame versions. """ model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=5, subarray=True) out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 4, True) assert (0 == np.max(out_model.groupdq)) def test_onecr_10_groups_neighbors_flagged(setup_inputs): """" A single CR in a 10 group exposure """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # two segments perfect fit, second segment has twice the slope model1.data[0, 0, 5, 5] = 15.0 model1.data[0, 1, 5, 5] = 20.0 model1.data[0, 2, 5, 5] = 25.0 model1.data[0, 3, 5, 5] = 30.0 model1.data[0, 4, 5, 5] = 35.0 model1.data[0, 5, 5, 5] = 140.0 model1.data[0, 6, 5, 5] = 150.0 model1.data[0, 7, 5, 5] = 160.0 model1.data[0, 8, 5, 5] = 170.0 model1.data[0, 9, 5, 5] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 4, True) assert (4 == np.max(out_model.groupdq[0, 5, 5, 5])) assert (4 == out_model.groupdq[0, 5, 5, 6]) assert (4 == out_model.groupdq[0, 5, 5, 4]) assert (4 == out_model.groupdq[0, 5, 6, 5]) assert (4 == out_model.groupdq[0, 5, 4, 5]) def test_nocr_100_groups_nframes1(setup_inputs): """" NO CR in a 100 group exposure to make sure that frames_per_group is passed correctly to twopoint_difference. This test recreates the problem found in issue #4571. """ grouptime = 3.0 ingain = 1 #to make the noise calculation simple inreadnoise = np.float64(7) ngroups = 100 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, nrows=100, ncols=100, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) model1.meta.exposure.nframes = 1 # two segments perfect fit, second segment has twice the slope model1.data[0, 0, 5, 5] = 14.0 model1.data[0, 1, 5, 5] = 20.0 model1.data[0, 2, 5, 5] = 27.0 model1.data[0, 3, 5, 5] = 30.0 model1.data[0, 4, 5, 5] = 38.0 model1.data[0, 5, 5, 5] = 40.0 model1.data[0, 6, 5, 5] = 50.0 model1.data[0, 7, 5, 5] = 52.0 model1.data[0, 8, 5, 5] = 63.0 model1.data[0, 9, 5, 5] = 68.0 for i in range(10,100): model1.data[0,i,5,5] = i * 5 out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 4, True) assert (0 == np.max(out_model.groupdq)) def test_twoints_onecr_each_10_groups_neighbors_flagged(setup_inputs): """" Two integrations with CRs in different locations. This makes sure we are correctly dealing with integrations. """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, nints=2, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # two segments perfect fit, second segment has twice the slope model1.data[0, 0, 5, 5] = 15.0 model1.data[0, 1, 5, 5] = 20.0 model1.data[0, 2, 5, 5] = 25.0 model1.data[0, 3, 5, 5] = 30.0 model1.data[0, 4, 5, 5] = 35.0 model1.data[0, 5, 5, 5] = 140.0 model1.data[0, 6, 5, 5] = 150.0 model1.data[0, 7, 5, 5] = 160.0 model1.data[0, 8, 5, 5] = 170.0 model1.data[0, 9, 5, 5] = 180.0 model1.data[1, 0, 15, 5] = 15.0 model1.data[1, 1, 15, 5] = 20.0 model1.data[1, 2, 15, 5] = 25.0 model1.data[1, 3, 15, 5] = 30.0 model1.data[1, 4, 15, 5] = 35.0 model1.data[1, 5, 15, 5] = 40.0 model1.data[1, 6, 15, 5] = 45.0 model1.data[1, 7, 15, 5] = 160.0 model1.data[1, 8, 15, 5] = 170.0 model1.data[1, 9, 15, 5] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 4, True) assert (4 == np.max(out_model.groupdq[0, 5, 5, 5])) assert (4 == out_model.groupdq[0, 5, 5, 6]) assert (4 == out_model.groupdq[0, 5, 5, 4]) assert (4 == out_model.groupdq[0, 5, 6, 5]) assert (4 == out_model.groupdq[0, 5, 4, 5]) assert (4 == out_model.groupdq[1, 7, 15, 5]) assert (4 == out_model.groupdq[1, 7, 15, 6]) assert (4 == out_model.groupdq[1, 7, 15, 4]) assert (4 == out_model.groupdq[1, 7, 16, 5]) assert (4 == out_model.groupdq[1, 7, 14, 5]) def test_flagging_of_CRs_across_slice_boundaries(setup_inputs): """" A multiprocessing test that has two CRs on the boundary between two slices. This makes sure that we are correctly flagging neighbors in different slices. """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, nints=2, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) nrows = model1.data.shape[3] num_cores = multiprocessing.cpu_count() max_cores = 'half' numslices = num_cores // 2 if numslices > 1: yincrement = int(nrows / numslices) # two segments perfect fit, second segment has twice the slope #add a CR on the last row of the first slice model1.data[0, 0, yincrement-1, 5] = 15.0 model1.data[0, 1, yincrement-1, 5] = 20.0 model1.data[0, 2, yincrement-1, 5] = 25.0 model1.data[0, 3, yincrement-1, 5] = 30.0 model1.data[0, 4, yincrement-1, 5] = 35.0 model1.data[0, 5, yincrement-1, 5] = 140.0 model1.data[0, 6, yincrement-1, 5] = 150.0 model1.data[0, 7, yincrement-1, 5] = 160.0 model1.data[0, 8, yincrement-1, 5] = 170.0 model1.data[0, 9, yincrement-1, 5] = 180.0 #add a CR on the first row of the second slice model1.data[1, 0, yincrement, 25] = 15.0 model1.data[1, 1, yincrement, 25] = 20.0 model1.data[1, 2, yincrement, 25] = 25.0 model1.data[1, 3, yincrement, 25] = 30.0 model1.data[1, 4, yincrement, 25] = 35.0 model1.data[1, 5, yincrement, 25] = 40.0 model1.data[1, 6, yincrement, 25] = 50.0 model1.data[1, 7, yincrement, 25] = 160.0 model1.data[1, 8, yincrement, 25] = 170.0 model1.data[1, 9, yincrement, 25] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, max_cores, 200, 4, True) #check that the neighbors of the CR on the last row were flagged assert (4 == out_model.groupdq[0, 5, yincrement-1, 5]) assert (4 == out_model.groupdq[0, 5, yincrement-1, 6]) assert (4 == out_model.groupdq[0, 5, yincrement-1, 4]) assert (4 == out_model.groupdq[0, 5, yincrement, 5]) assert (4 == out_model.groupdq[0, 5, yincrement-2, 5]) # check that the neighbors of the CR on the first row were flagged assert (4 == out_model.groupdq[1, 7, yincrement, 25]) assert (4 == out_model.groupdq[1, 7, yincrement, 26]) assert (4 == out_model.groupdq[1, 7, yincrement, 24]) assert (4 == out_model.groupdq[1, 7, yincrement+1, 25]) assert (4 == out_model.groupdq[1, 7, yincrement-1, 25]) def test_twoints_onecr_10_groups_neighbors_flagged_multi(setup_inputs): """" A multiprocessing test that has two CRs on the boundary between two slices in different integrations. This makes sure that we are correctly flagging neighbors in different slices and that we are parsing the integrations correctly. """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, nints=2, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # two segments perfect fit, second segment has twice the slope model1.data[0, 0, 5, 5] = 15.0 model1.data[0, 1, 5, 5] = 20.0 model1.data[0, 2, 5, 5] = 25.0 model1.data[0, 3, 5, 5] = 30.0 model1.data[0, 4, 5, 5] = 35.0 model1.data[0, 5, 5, 5] = 140.0 model1.data[0, 6, 5, 5] = 150.0 model1.data[0, 7, 5, 5] = 160.0 model1.data[0, 8, 5, 5] = 170.0 model1.data[0, 9, 5, 5] = 180.0 model1.data[1, 0, 15, 5] = 15.0 model1.data[1, 1, 15, 5] = 20.0 model1.data[1, 2, 15, 5] = 25.0 model1.data[1, 3, 15, 5] = 30.0 model1.data[1, 4, 15, 5] = 35.0 model1.data[1, 5, 15, 5] = 40.0 model1.data[1, 6, 15, 5] = 45.0 model1.data[1, 7, 15, 5] = 160.0 model1.data[1, 8, 15, 5] = 170.0 model1.data[1, 9, 15, 5] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 'half', 200, 4, True) assert (4 == np.max(out_model.groupdq[0, 5, 5, 5])) assert (4 == out_model.groupdq[0, 5, 5, 6]) assert (4 == out_model.groupdq[0, 5, 5, 4]) assert (4 == out_model.groupdq[0, 5, 6, 5]) assert (4 == out_model.groupdq[0, 5, 4, 5]) assert (4 == out_model.groupdq[1, 7, 15, 5]) assert (4 == out_model.groupdq[1, 7, 15, 6]) assert (4 == out_model.groupdq[1, 7, 15, 4]) assert (4 == out_model.groupdq[1, 7, 16, 5]) assert (4 == out_model.groupdq[1, 7, 14, 5]) @pytest.mark.skip(reason="Test is only used to test performance issue. No need to run every time.") def test_every_pixel_CR_neighbors_flagged(setup_inputs): """" A multiprocessing test that has a jump in every pixel. This is used to test the performance gain from multiprocessing. """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # two segments perfect fit, second segment has twice the slope model1.data[0, 0, :, :] = 15.0 model1.data[0, 1, :, :] = 20.0 model1.data[0, 2, :, :] = 25.0 model1.data[0, 3, :, :] = 30.0 model1.data[0, 4, :, :] = 35.0 model1.data[0, 5, :, :] = 140.0 model1.data[0, 6, :, :] = 150.0 model1.data[0, 7, :, :] = 160.0 model1.data[0, 8, :, :] = 170.0 model1.data[0, 9, :, :] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 'half', 200, 4, True) assert (4 == np.max(out_model.groupdq[0, 5, 5, 5])) assert (4 == out_model.groupdq[0, 5, 5, 6]) assert (4 == out_model.groupdq[0, 5, 5, 4]) assert (4 == out_model.groupdq[0, 5, 6, 5]) assert (4 == out_model.groupdq[0, 5, 4, 5]) def test_crs_on_edge_with_neighbor_flagging(setup_inputs): """" A test to make sure that the neighbors of CRs on the edges of the array are flagged correctly. """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # two segments perfect fit, second segment has twice the slope # CR on 1st row model1.data[0, 0, 0, 15] = 15.0 model1.data[0, 1, 0, 15] = 20.0 model1.data[0, 2, 0, 15] = 25.0 model1.data[0, 3, 0, 15] = 30.0 model1.data[0, 4, 0, 15] = 35.0 model1.data[0, 5, 0, 15] = 140.0 model1.data[0, 6, 0, 15] = 150.0 model1.data[0, 7, 0, 15] = 160.0 model1.data[0, 8, 0, 15] = 170.0 model1.data[0, 9, 0, 15] = 180.0 # CR on last row model1.data[0, 0, 1023, 5] = 15.0 model1.data[0, 1, 1023, 5] = 20.0 model1.data[0, 2, 1023, 5] = 25.0 model1.data[0, 3, 1023, 5] = 30.0 model1.data[0, 4, 1023, 5] = 35.0 model1.data[0, 5, 1023, 5] = 140.0 model1.data[0, 6, 1023, 5] = 150.0 model1.data[0, 7, 1023, 5] = 160.0 model1.data[0, 8, 1023, 5] = 170.0 model1.data[0, 9, 1023, 5] = 180.0 # CR on 1st column model1.data[0, 0, 5, 0] = 15.0 model1.data[0, 1, 5, 0] = 20.0 model1.data[0, 2, 5, 0] = 25.0 model1.data[0, 3, 5, 0] = 30.0 model1.data[0, 4, 5, 0] = 35.0 model1.data[0, 5, 5, 0] = 140.0 model1.data[0, 6, 5, 0] = 150.0 model1.data[0, 7, 5, 0] = 160.0 model1.data[0, 8, 5, 0] = 170.0 model1.data[0, 9, 5, 0] = 180.0 # CR on last column model1.data[0, 0, 15, 1027] = 15.0 model1.data[0, 1, 15, 1027] = 20.0 model1.data[0, 2, 15, 1027] = 25.0 model1.data[0, 3, 15, 1027] = 30.0 model1.data[0, 4, 15, 1027] = 35.0 model1.data[0, 5, 15, 1027] = 140.0 model1.data[0, 6, 15, 1027] = 150.0 model1.data[0, 7, 15, 1027] = 160.0 model1.data[0, 8, 15, 1027] = 170.0 model1.data[0, 9, 15, 1027] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 10, True) # flag CR and three neighbors of first row CR assert (4 == out_model.groupdq[0, 5, 0, 15]) assert (4 == out_model.groupdq[0, 5, 1, 15]) assert (4 == out_model.groupdq[0, 5, 0, 14]) assert (4 == out_model.groupdq[0, 5, 0, 16]) assert (out_model.groupdq[0, 5, -1, 15] == 0) # The one not to flag # flag CR and three neighbors of last row CR assert (4 == out_model.groupdq[0, 5, 1023, 5]) assert (4 == out_model.groupdq[0, 5, 1022, 5]) assert (4 == out_model.groupdq[0, 5, 1023, 4]) assert (4 == out_model.groupdq[0, 5, 1023, 6]) # flag CR and three neighbors of first column CR assert (4 == out_model.groupdq[0, 5, 5, 0]) assert (4 == out_model.groupdq[0, 5, 6, 0]) assert (4 == out_model.groupdq[0, 5, 4, 0]) assert (4 == out_model.groupdq[0, 5, 5, 1]) assert (out_model.groupdq[0, 5, 5, -1] == 0)# The one not to flag # flag CR and three neighbors of last column CR assert (4 == out_model.groupdq[0, 5, 15, 1027]) assert (4 == out_model.groupdq[0, 5, 15, 1026]) assert (4 == out_model.groupdq[0, 5, 16, 1027]) assert (4 == out_model.groupdq[0, 5, 14, 1027]) def test_onecr_10_groups(setup_inputs): """" A test to make sure that neighbors are not flagged when they are not requested to be flagged. """ grouptime = 3.0 ingain = 200 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # two segments perfect fit, second segment has twice the slope model1.data[0, 0, 5, 5] = 15.0 model1.data[0, 1, 5, 5] = 20.0 model1.data[0, 2, 5, 5] = 25.0 model1.data[0, 3, 5, 5] = 30.0 model1.data[0, 4, 5, 5] = 35.0 model1.data[0, 5, 5, 5] = 140.0 model1.data[0, 6, 5, 5] = 150.0 model1.data[0, 7, 5, 5] = 160.0 model1.data[0, 8, 5, 5] = 170.0 model1.data[0, 9, 5, 5] = 180.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 10, False) assert (out_model.groupdq[0, 5, 5, 5] == 4) assert (out_model.groupdq[0, 5, 4, 5] == 0) assert (out_model.groupdq[0, 5, 6, 5] == 0) assert (out_model.groupdq[0, 5, 5, 6] == 0) assert (out_model.groupdq[0, 5, 5, 4] == 0) def test_onecr_10_groups_fullarray(setup_inputs): """" A test that has a cosmic ray in the 5th group for all pixels except column 10. In column 10 the jump is in the 7th group. """ grouptime = 3.0 ingain = 5 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) # model1.data[0, 0, 5, :] = 15.0 model1.data[0, 1, 5, :] = 20.0 model1.data[0, 2, 5, :] = 25.0 model1.data[0, 3, 5, :] = 30.0 model1.data[0, 4, 5, :] = 35.0 model1.data[0, 5, 5, :] = 140.0 model1.data[0, 6, 5, :] = 150.0 model1.data[0, 7, 5, :] = 160.0 model1.data[0, 8, 5, :] = 170.0 model1.data[0, 9, 5, :] = 180.0 # move the CR to group 7 for row 10 and make difference be 300 model1.data[0, 3, 5, 10] = 100 model1.data[0, 4, 5, 10] = 130 model1.data[0, 5, 5, 10] = 160 model1.data[0, 6, 5, 10] = 190 model1.data[0, 7, 5, 10] = 400 model1.data[0, 8, 5, 10] = 410 model1.data[0, 9, 5, 10] = 420 out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 10, False) assert (np.all(out_model.groupdq[0, 5, 5, 0:10] == 4)) # The jump is in group 5 for columns 0-9 assert (out_model.groupdq[0, 7, 5, 10] == 4) # The jump is in group 7 for column 10 assert (np.all(out_model.groupdq[0, 5, 5, 11:] == 4)) # The jump is in group 5 for columns 11+ def test_onecr_50_groups(setup_inputs): """" A test with a fifty group integration. There are two jumps in pixel 5,5. One in group 5 and one in group 30. """ grouptime = 3.0 ingain = 5 inreadnoise = np.float64(7) ngroups = 50 model1, gdq, rnModel, pixdq, err, gain = setup_inputs(ngroups=ngroups, gain=ingain, readnoise=inreadnoise, deltatime=grouptime) model1.data[0, 0, 5, 5] = 15.0 model1.data[0, 1, 5, 5] = 20.0 model1.data[0, 2, 5, 5] = 25.0 model1.data[0, 3, 5, 5] = 30.0 model1.data[0, 4, 5, 5] = 35.0 model1.data[0, 5, 5, 5] = 140.0 model1.data[0, 6, 5, 5] = 150.0 model1.data[0, 7, 5, 5] = 160.0 model1.data[0, 8, 5, 5] = 170.0 model1.data[0, 9, 5, 5] = 180.0 model1.data[0, 10:30, 5, 5] = np.arange(190, 290, 5) model1.data[0, 30:50, 5, 5] = np.arange(500, 600, 5) out_model = detect_jumps(model1, gain, rnModel, 4.0, 1, 200, 10, False) assert (out_model.groupdq[0, 5, 5, 5] == 4) # CR in group 5 assert (out_model.groupdq[0, 30, 5, 5] == 4) # CR in group 30 assert (np.all(out_model.groupdq[0, 6:30, 5, 5] == 0)) # groups in between are not flagged def test_single_CR_neighbor_flag( setup_inputs): """" A single CR in a 10 group exposure. Tests that: - if neighbor-flagging is set, the 4 neighboring pixels *ARE* flagged, and - if neighbor-flagging is *NOT* set, the 4 neighboring pixels are *NOT* flagged """ grouptime = 3.0 ingain = 5 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = \ setup_inputs( ngroups=ngroups, nrows=5, ncols=6, gain=ingain, readnoise=inreadnoise, deltatime=grouptime ) # two segments perfect fit, second segment has twice the slope model1.data[0, 0, 3, 3] = 15.0 model1.data[0, 1, 3, 3] = 20.0 model1.data[0, 2, 3, 3] = 25.0 model1.data[0, 3, 3, 3] = 30.0 model1.data[0, 4, 3, 3] = 35.0 model1.data[0, 5, 3, 3] = 140.0 model1.data[0, 6, 3, 3] = 150.0 model1.data[0, 7, 3, 3] = 160.0 model1.data[0, 8, 3, 3] = 170.0 model1.data[0, 9, 3, 3] = 180.0 # Flag neighbors out_model = detect_jumps( model1, gain, rnModel, 4.0, 1, 200, 4, True ) assert (4 == np.max(out_model.groupdq[0, 5, 3, 3])) assert (4 == out_model.groupdq[0, 5, 3, 4]) assert (4 == out_model.groupdq[0, 5, 3, 2]) assert (4 == out_model.groupdq[0, 5, 2, 3]) assert (4 == out_model.groupdq[0, 5, 4, 3]) # Do not flag neighbors out_model = detect_jumps( model1, gain, rnModel, 4.0, 1, 200, 4, False ) assert (4 == np.max(out_model.groupdq[0, 5, 3, 3])) assert (0 == out_model.groupdq[0, 5, 3, 4]) assert (0 == out_model.groupdq[0, 5, 3, 2]) assert (0 == out_model.groupdq[0, 5, 2, 3]) assert (0 == out_model.groupdq[0, 5, 4, 3]) def test_proc(setup_inputs): """" A single CR in a 10 group exposure. Verify that the pixels flagged using multiprocessing are identical to the pixels flagged when no multiprocessing is done. """ grouptime = 3.0 ingain = 5 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = \ setup_inputs( ngroups=ngroups, nrows=5, ncols=6, nints=2, gain=ingain, readnoise=inreadnoise, deltatime=grouptime ) model1.data[0, 0, 2, 3] = 15.0 model1.data[0, 1, 2, 3] = 21.0 model1.data[0, 2, 2, 3] = 25.0 model1.data[0, 3, 2, 3] = 30.2 model1.data[0, 4, 2, 3] = 35.0 model1.data[0, 5, 2, 3] = 140.0 model1.data[0, 6, 2, 3] = 151.0 model1.data[0, 7, 2, 3] = 160.0 model1.data[0, 8, 2, 3] = 170.0 model1.data[0, 9, 2, 3] = 180.0 out_model_a = detect_jumps( model1, gain, rnModel, 4.0, 'half', 200, 4, True ) out_model_b = detect_jumps( model1, gain, rnModel, 4.0, None, 200, 4, True ) assert( out_model_a.groupdq == out_model_b.groupdq ).all() out_model_c = detect_jumps( model1, gain, rnModel, 4.0, 'All', 200, 4, True ) assert( out_model_a.groupdq == out_model_c.groupdq ).all() def test_adjacent_CRs( setup_inputs ): """ Three CRs in a 10 group exposure; the CRs have overlapping neighboring pixels. This test makes sure that the correct pixels are flagged. """ grouptime = 3.0 ingain = 5 inreadnoise = np.float64(7) ngroups = 10 model1, gdq, rnModel, pixdq, err, gain = \ setup_inputs( ngroups=ngroups, nrows=5, ncols=6, gain=ingain, readnoise=inreadnoise, deltatime=grouptime ) # Populate arrays for 1st CR, centered at (x=2, y=3) x=2; y=3 model1.data[0, 0, y, x] = 15.0 model1.data[0, 1, y, x] = 20.0 model1.data[0, 2, y, x] = 26.0 model1.data[0, 3, y, x] = 30.0 model1.data[0, 4, y, x] = 35.0 model1.data[0, 5, y, x] = 140.0 model1.data[0, 6, y, x] = 150.0 model1.data[0, 7, y, x] = 161.0 model1.data[0, 8, y, x] = 170.0 model1.data[0, 9, y, x] = 180.0 # Populate arrays for 2nd CR, centered at (x=2, y=2) x=2; y=2 model1.data[0, 0, y, x] = 20.0 model1.data[0, 1, y, x] = 30.0 model1.data[0, 2, y, x] = 41.0 model1.data[0, 3, y, x] = 51.0 model1.data[0, 4, y, x] = 62.0 model1.data[0, 5, y, x] = 170.0 model1.data[0, 6, y, x] = 200.0 model1.data[0, 7, y, x] = 231.0 model1.data[0, 8, y, x] = 260.0 model1.data[0, 9, y, x] = 290.0 # Populate arrays for 3rd CR, centered at (x=3, y=2) x=3; y=2 model1.data[0, 0, y, x] = 120.0 model1.data[0, 1, y, x] = 140.0 model1.data[0, 2, y, x] = 161.0 model1.data[0, 3, y, x] = 181.0 model1.data[0, 4, y, x] = 202.0 model1.data[0, 5, y, x] = 70.0 model1.data[0, 6, y, x] = 100.0 model1.data[0, 7, y, x] = 131.0 model1.data[0, 8, y, x] = 160.0 model1.data[0, 9, y, x] = 190.0 out_model = detect_jumps(model1, gain, rnModel, 4.0, 'half', 200, 4, True) # 1st CR (centered at x=2, y=3) assert (4 == out_model.groupdq[ 0,5,2,2 ]) assert (4 == out_model.groupdq[ 0,5,3,1 ]) assert (4 == out_model.groupdq[ 0,5,3,2 ]) assert (4 == out_model.groupdq[ 0,5,3,3 ]) assert (4 == out_model.groupdq[ 0,5,4,2 ]) # 2nd CR (centered at x=2, y=2) assert (4 == out_model.groupdq[ 0,5,1,2 ]) assert (4 == out_model.groupdq[ 0,5,2,1 ]) assert (4 == out_model.groupdq[ 0,5,2,3 ]) # 3rd CR (centered at x=3, y=2) assert (4 == out_model.groupdq[ 0,5,1,3 ]) assert (4 == out_model.groupdq[ 0,5,2,4 ]) # Need test for multi-ints near zero with positive and negative slopes @pytest.fixture def setup_inputs(): def _setup(ngroups=10, readnoise=10, nints=1, nrows=1024, ncols=1032, nframes=1, grouptime=1.0, gain=1, deltatime=1, gain_subarray = False, readnoise_subarray = False, subarray = False): times = np.array(list(range(ngroups)), dtype=np.float64) * deltatime gain = np.ones(shape=(nrows, ncols), dtype=np.float64) * gain pixdq = np.zeros(shape=(nrows, ncols), dtype=np.float64) read_noise = np.full((nrows, ncols), readnoise, dtype=np.float64) gdq = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.uint32) if subarray: data = np.zeros(shape=(nints, ngroups, 20, 20), dtype=np.float64) err = np.ones(shape=(nints, ngroups, 20, 20), dtype=np.float64) else: data = np.zeros(shape=(nints, ngroups, nrows, ncols), dtype=np.float64) err = np.ones(shape=(nints, ngroups, nrows, ncols), dtype=np.float64) model1 = RampModel(data=data, err=err, pixeldq=pixdq, groupdq=gdq, times=times) model1.meta.instrument.name = 'MIRI' model1.meta.instrument.detector = 'MIRIMAGE' model1.meta.instrument.filter = 'F480M' model1.meta.observation.date = '2015-10-13' model1.meta.exposure.type = 'MIR_IMAGE' model1.meta.exposure.group_time = deltatime model1.meta.subarray.name = 'FULL' model1.meta.subarray.xstart = 1 model1.meta.subarray.ystart = 1 if subarray: model1.meta.subarray.xsize = 20 model1.meta.subarray.ysize = 20 else: model1.meta.subarray.xsize = ncols model1.meta.subarray.ysize = nrows model1.meta.exposure.frame_time = deltatime model1.meta.exposure.ngroups = ngroups model1.meta.exposure.group_time = deltatime model1.meta.exposure.nframes = 1 model1.meta.exposure.groupgap = 0 gain = GainModel(data=gain) gain.meta.instrument.name = 'MIRI' gain.meta.subarray.xstart = 1 gain.meta.subarray.ystart = 1 gain.meta.subarray.xsize = ncols gain.meta.subarray.ysize = nrows rnModel = ReadnoiseModel(data=read_noise) rnModel.meta.instrument.name = 'MIRI' rnModel.meta.subarray.xstart = 1 rnModel.meta.subarray.ystart = 1 rnModel.meta.subarray.xsize = ncols rnModel.meta.subarray.ysize = nrows return model1, gdq, rnModel, pixdq, err, gain return _setup
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,497
mperrin/jwst
refs/heads/master
/jwst/assign_wcs/tests/test_nirspec.py
""" Test functions for NIRSPEC WCS - all modes. """ import os.path import pytest import numpy as np from numpy.testing import assert_allclose from astropy.io import fits from astropy.modeling import models as astmodels from astropy import wcs as astwcs import astropy.units as u import astropy.coordinates as coords from gwcs import wcs from jwst import datamodels from jwst.transforms.models import Slit from jwst.assign_wcs import nirspec from jwst.assign_wcs import assign_wcs_step from . import data from jwst.assign_wcs.util import MSAFileError data_path = os.path.split(os.path.abspath(data.__file__))[0] wcs_kw = {'wcsaxes': 2, 'ra_ref': 165, 'dec_ref': 54, 'v2_ref': -8.3942412, 'v3_ref': -5.3123744, 'roll_ref': 37, 'crpix1': 1024, 'crpix2': 1024, 'cdelt1': .08, 'cdelt2': .08, 'ctype1': 'RA---TAN', 'ctype2': 'DEC--TAN', 'pc1_1': 1, 'pc1_2': 0, 'pc2_1': 0, 'pc2_2': 1 } slit_fields_num = ["shutter_id", "dither_position", "xcen", "ycen", "ymin", "ymax", "quadrant", "source_id", "stellarity", "source_xpos", "source_ypos"] slit_fields_str = ["name", "shutter_state", "source_name", "source_alias"] def _compare_slits(s1, s2): for f in slit_fields_num: assert_allclose(getattr(s1, f), getattr(s2, f)) for f in slit_fields_str: assert getattr(s1, f) == getattr(s2, f) def get_file_path(filename): """ Construct an absolute path. """ return os.path.join(data_path, filename) def create_hdul(detector='NRS1'): """ Create a fits HDUList instance. """ hdul = fits.HDUList() phdu = fits.PrimaryHDU() phdu.header['instrume'] = 'NIRSPEC' phdu.header['detector'] = detector phdu.header['time-obs'] = '8:59:37' phdu.header['date-obs'] = '2016-09-05' scihdu = fits.ImageHDU() scihdu.header['EXTNAME'] = "SCI" for item in wcs_kw.items(): scihdu.header[item[0]] = item[1] hdul.append(phdu) hdul.append(scihdu) return hdul def create_reference_files(datamodel): """ Create a dict {reftype: reference_file}. """ refs = {} step = assign_wcs_step.AssignWcsStep() for reftype in assign_wcs_step.AssignWcsStep.reference_file_types: refs[reftype] = step.get_reference_file(datamodel, reftype) return refs def create_nirspec_imaging_file(): image = create_hdul() image[0].header['exp_type'] = 'NRS_IMAGE' image[0].header['filter'] = 'F290LP' image[0].header['grating'] = 'MIRROR' return image def create_nirspec_mos_file(): image = create_hdul() image[0].header['exp_type'] = 'NRS_MSASPEC' image[0].header['filter'] = 'F170LP' image[0].header['grating'] = 'G235M' image[0].header['PATT_NUM'] = 1 msa_status_file = get_file_path('SPCB-GD-A.msa.fits.gz') image[0].header['MSACONFG'] = msa_status_file return image def create_nirspec_ifu_file(filter, grating, lamp='N/A', detector='NRS1'): image = create_hdul(detector) image[0].header['exp_type'] = 'NRS_IFU' image[0].header['filter'] = filter image[0].header['grating'] = grating image[1].header['crval3'] = 0 image[1].header['wcsaxes'] = 3 image[1].header['ctype3'] = 'WAVE' image[0].header['lamp'] = lamp image[0].header['GWA_XTIL'] = 0.3318742513656616 image[0].header['GWA_YTIL'] = 0.1258982867002487 return image def create_nirspec_fs_file(grating, filter, lamp="N/A"): image = create_hdul() image[0].header['exp_type'] = 'NRS_FIXEDSLIT' image[0].header['filter'] = filter image[0].header['grating'] = grating image[0].header['lamp'] = lamp image[1].header['crval3'] = 0 image[1].header['wcsaxes'] = 3 image[1].header['ctype3'] = 'WAVE' image[0].header['GWA_XTIL'] = 0.3316612243652344 image[0].header['GWA_YTIL'] = 0.1260581910610199 image[0].header['SUBARRAY'] = "FULL" return image def test_nirspec_imaging(): """ Test Nirspec Imaging mode using build 6 reference files. """ #Test creating the WCS f = create_nirspec_imaging_file() im = datamodels.ImageModel(f) refs = create_reference_files(im) pipe = nirspec.create_pipeline(im, refs, slit_y_range=[-.5, .5]) w = wcs.WCS(pipe) im.meta.wcs = w # Test evaluating the WCS im.meta.wcs(1, 2) def test_nirspec_ifu_against_esa(): """ Test Nirspec IFU mode using CV3 reference files. """ ref = fits.open(get_file_path('Trace_IFU_Slice_00_SMOS-MOD-G1M-17-5344175105_30192_JLAB88.fits')) # Test NRS1 pyw = astwcs.WCS(ref['SLITY1'].header) hdul = create_nirspec_ifu_file("OPAQUE", "G140M") im = datamodels.ImageModel(hdul) im.meta.filename = "test_ifu.fits" refs = create_reference_files(im) pipe = nirspec.create_pipeline(im, refs, slit_y_range=[-.5, .5]) w = wcs.WCS(pipe) im.meta.wcs = w # Test evaluating the WCS (slice 0) w0 = nirspec.nrs_wcs_set_input(im, 0) # get positions within the slit and the coresponding lambda slit1 = ref['SLITY1'].data # y offset on the slit lam = ref['LAMBDA1'].data # filter out locations outside the slit cond = np.logical_and(slit1 < .5, slit1 > -.5) y, x = cond.nonzero() # 0-based x, y = pyw.wcs_pix2world(x, y, 0) # The pipeline accepts 0-based cooridnates x -= 1 y -= 1 sca2world = w0.get_transform('sca', 'msa_frame') _, slit_y, lp = sca2world(x, y) lp *= 10**-6 assert_allclose(lp, lam[cond], atol=1e-13) def test_nirspec_fs_esa(): """ Test Nirspec FS mode using build 6 reference files. """ #Test creating the WCS filename = create_nirspec_fs_file(grating="G140M", filter="F100LP") im = datamodels.ImageModel(filename) im.meta.filename = "test_fs.fits" refs = create_reference_files(im) pipe = nirspec.create_pipeline(im, refs, slit_y_range=[-.5, .5]) w = wcs.WCS(pipe) im.meta.wcs = w # Test evaluating the WCS w1 = nirspec.nrs_wcs_set_input(im, "S200A1") ref = fits.open(get_file_path('Trace_SLIT_A_200_1_V84600010001P0000000002101_39547_JLAB88.fits')) pyw = astwcs.WCS(ref[1].header) # get positions within the slit and the coresponding lambda slit1 = ref[5].data # y offset on the slit lam = ref[4].data # filter out locations outside the slit cond = np.logical_and(slit1 < .5, slit1 > -.5) y, x = cond.nonzero() # 0-based x, y = pyw.wcs_pix2world(x, y, 0) # The pipeline works with 0-based coordinates x -= 1 y -= 1 sca2world = w1.get_transform('sca', 'v2v3') ra, dec, lp = sca2world(x, y) # w1 now outputs in microns hence the 1e6 factor lp *= 1e-6 lam = lam[cond] nan_cond = ~np.isnan(lp) assert_allclose(lp[nan_cond], lam[nan_cond], atol=10**-13) ref.close() def test_correct_tilt(): """ Example provided by Catarina. """ disp = datamodels.DisperserModel() xtilt = 0.35896975 ytilt = 0.1343827 # ztilt = None corrected_theta_x = 0.02942671219861111 corrected_theta_y = 0.00018649006677464447 # corrected_theta_z = -0.2523269848788889 disp.gwa_tiltx = {'temperatures': [39.58], 'tilt_model': astmodels.Polynomial1D(1, c0=3307.85402614, c1=-9182.87552123), 'unit': 'arcsec', 'zeroreadings': [0.35972327]} disp.gwa_tilty = {'temperatures': [39.58], 'tilt_model': astmodels.Polynomial1D(1, c0=0.0, c1=0.0), 'unit': 'arcsec', 'zeroreadings': [0.0]} disp.meta = {'instrument': {'name': 'NIRSPEC', 'detector': 'NRS1'}, 'reftype': 'DISPERSER'} disp.theta_x = 0.02942671219861111 disp.theta_y = -0.0007745488724972222 # disp.theta_z = -0.2523269848788889 disp.tilt_x = 0.0 disp.tilt_y = -8.8 disp_corrected = nirspec.correct_tilt(disp, xtilt, ytilt)#, ztilt) assert np.isclose(disp_corrected.theta_x, corrected_theta_x) # assert(np.isclose(disp_corrected['theta_z'], corrected_theta_z)) assert np.isclose(disp_corrected.theta_y, corrected_theta_y) def test_msa_configuration_normal(): """ Test the get_open_msa_slits function. """ # Test 1: Reasonably normal as well msa_meta_id = 12 msaconfl = get_file_path('msa_configuration.fits') dither_position = 1 slitlet_info = nirspec.get_open_msa_slits(msaconfl, msa_meta_id, dither_position, slit_y_range=[-.5, .5]) ref_slit = Slit(55, 9376, 1, 251, 26, -5.15, 0.55, 4, 1, '1111x', '95065_1', '2122', 0.13, -0.31716078999999997, -0.18092266) _compare_slits(slitlet_info[0], ref_slit) def test_msa_configuration_no_background(): """ Test the get_open_msa_slits function. """ # Test 2: Two main shutters, not allowed and should fail msa_meta_id = 13 msaconfl = get_file_path('msa_configuration.fits') dither_position = 1 with pytest.raises(MSAFileError): nirspec.get_open_msa_slits(msaconfl, msa_meta_id, dither_position, slit_y_range=[-.5, .5]) def test_msa_configuration_all_background(): """ Test the get_open_msa_slits function. """ # Test 3: No non-background, not acceptable. msa_meta_id = 14 msaconfl = get_file_path('msa_configuration.fits') dither_position = 1 slitlet_info = nirspec.get_open_msa_slits(msaconfl, msa_meta_id, dither_position, slit_y_range=[-.5, .5]) ref_slit = Slit(57, 8646, 1, 251, 24, -2.85, .55, 4, 0, '11x', 'background_57', 'bkg_57', 0, -0.5, -0.5) _compare_slits(slitlet_info[0], ref_slit) def test_msa_configuration_row_skipped(): """ Test the get_open_msa_slits function. """ # Test 4: One row is skipped, should be acceptable. msa_meta_id = 15 msaconfl = get_file_path('msa_configuration.fits') dither_position = 1 slitlet_info = nirspec.get_open_msa_slits(msaconfl, msa_meta_id, dither_position, slit_y_range=[-.5, .5]) ref_slit = Slit(58, 8646, 1, 251, 24, -2.85, 5.15, 4, 1, '11x1011', '95065_1', '2122', 0.130, -0.31716078999999997, -0.18092266) _compare_slits(slitlet_info[0], ref_slit) def test_msa_configuration_multiple_returns(): """ Test the get_open_msa_slits function. """ # Test 4: One row is skipped, should be acceptable. msa_meta_id = 16 msaconfl = get_file_path('msa_configuration.fits') dither_position = 1 slitlet_info = nirspec.get_open_msa_slits(msaconfl, msa_meta_id, dither_position, slit_y_range=[-.5, .5]) ref_slit1 = Slit(59, 8651, 1, 256, 24, -2.85, 5.15, 4, 1, '11x1011', '95065_1', '2122', 0.13000000000000003, -0.31716078999999997, -0.18092266) ref_slit2 = Slit(60, 11573, 1, 258, 32, -2.85, 4, 4, 2, '11x111', '95065_2', '172', 0.70000000000000007, -0.31716078999999997, -0.18092266) _compare_slits(slitlet_info[0], ref_slit1) _compare_slits(slitlet_info[1], ref_slit2) open_shutters = [[24], [23, 24], [22, 23, 25, 27], [22, 23, 25, 27, 28]] main_shutter = [24, 23, 25, 28] result = ["x", "x1", "110x01", "110101x"] test_data = list(zip(open_shutters, main_shutter, result)) @pytest.mark.parametrize(('open_shutters', 'main_shutter', 'result'), test_data) def test_shutter_state(open_shutters, main_shutter, result): shutter_state = nirspec._shutter_id_to_str(open_shutters, main_shutter) assert shutter_state == result def test_slit_projection_on_detector(): step = assign_wcs_step.AssignWcsStep() hdul = create_nirspec_fs_file(grating="G395M", filter="OPAQUE", lamp="ARGON") hdul[0].header['DETECTOR'] = 'NRS2' im = datamodels.ImageModel(hdul) refs = {} for reftype in step.reference_file_types: refs[reftype] = step.get_reference_file(im, reftype) open_slits = nirspec.get_open_slits(im, refs) assert len(open_slits) == 1 assert open_slits[0].name == "S200B1" hdul[0].header['DETECTOR'] = 'NRS1' im = datamodels.ImageModel(hdul) open_slits = nirspec.get_open_slits(im, refs) assert len(open_slits) == 4 names = [s.name for s in open_slits] assert "S200A1" in names assert "S200A2" in names assert "S400A1" in names assert "S1600A1" in names def test_missing_msa_file(): image = create_nirspec_mos_file() model = datamodels.ImageModel(image) model.meta.instrument.msa_metadata_file = "" with pytest.raises(MSAFileError): assign_wcs_step.AssignWcsStep.call(model) model.meta.instrument.msa_metadata_file = "missing.fits" with pytest.raises(MSAFileError): assign_wcs_step.AssignWcsStep.call(model) def test_open_slits(): """ Test that get_open_slits works with MSA data. Issue #2321 """ image = create_nirspec_mos_file() model = datamodels.ImageModel(image) msaconfl = get_file_path('msa_configuration.fits') model.meta.instrument.msa_metadata_file = msaconfl model.meta.instrument.msa_metadata_id = 12 slits = nirspec.get_open_slits(model) assert len(slits) == 1 def test_shutter_size_on_sky(): """ Test the size of a MOS shutter on sky is ~ .2 x .4 arcsec. """ image = create_nirspec_mos_file() model = datamodels.ImageModel(image) msaconfl = get_file_path('msa_configuration.fits') model.meta.instrument.msa_metadata_file = msaconfl model.meta.instrument.msa_metadata_id = 12 refs = create_reference_files(model) pipe = nirspec.create_pipeline(model, refs, slit_y_range=(-.5, .5)) w = wcs.WCS(pipe) model.meta.wcs = w slit = w.get_transform('slit_frame', 'msa_frame').slits[0] wslit = nirspec.nrs_wcs_set_input(model, slit.name) virtual_corners_x = [-.5, -.5, .5, .5, -.5] virtual_corners_y = [-.5, .5, .5, -.5, -.5] input_lam = [2e-6] * 5 slit2world = wslit.get_transform('slit_frame', 'world') ra, dec, lam = slit2world(virtual_corners_x, virtual_corners_y, input_lam) sky = coords.SkyCoord(ra*u.deg, dec*u.deg) sep_x = sky[0].separation(sky[3]).to(u.arcsec) sep_y = sky[0].separation(sky[1]).to(u.arcsec) assert sep_x.value > 0.193 assert sep_x.value < 0.194 assert sep_y.value > 0.45 assert sep_y.value < 0.46
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,498
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/associations/test_generate.py
"""Test general asn_generate operations""" import pytest from jwst.associations import ( generate, load_asn ) @pytest.mark.slow def test_generate(full_pool_rules): """Run a full sized pool using all rules""" pool, rules, pool_fname = full_pool_rules asns = generate(pool, rules) assert len(asns) == 99 for asn in asns: asn_name, asn_store = asn.dump() asn_table = load_asn(asn_store) schemas = rules.validate(asn_table) assert len(schemas) > 0 @pytest.mark.slow def test_serialize(full_pool_rules): """Test serializing roundtripping""" pool, rules, pool_fname = full_pool_rules asns = generate(pool, rules) for asn in asns: for format in asn.ioregistry: fname, serialized = asn.dump(format=format) assert serialized is not None recovered = load_asn(serialized) assert recovered is not None
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,499
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py
import pytest from jwst.tests.base_classes import BaseJWSTTestSteps from jwst.tests.base_classes import pytest_generate_tests # noqa: F401 from jwst.refpix import RefPixStep from jwst.dark_current import DarkCurrentStep from jwst.dq_init import DQInitStep from jwst.extract_1d import Extract1dStep from jwst.extract_2d import Extract2dStep from jwst.flatfield import FlatFieldStep from jwst.group_scale import GroupScaleStep from jwst.jump import JumpStep from jwst.linearity import LinearityStep from jwst.photom import PhotomStep from jwst.saturation import SaturationStep from jwst.superbias import SuperBiasStep # Parameterized regression tests for NIRISS processing # All tests in this set run with 1 input file and # only generate 1 output for comparison. # @pytest.mark.bigdata class TestNIRSpecSteps(BaseJWSTTestSteps): input_loc = 'nirspec' params = {'test_steps': [dict(input='jw00023001001_01101_00001_NRS1_dq_init.fits', test_dir='test_bias_drift', step_class=RefPixStep, step_pars=dict(odd_even_columns=True, use_side_ref_pixels=False, side_smoothing_length=10, side_gain=1.0), output_truth='jw00023001001_01101_00001_NRS1_bias_drift.fits', output_hdus=[], id='refpix_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_saturation.fits', test_dir='test_dark_step', step_class=DarkCurrentStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_dark_current.fits', output_hdus=[], id='dark_current_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_uncal.fits', test_dir='test_dq_init', step_class=DQInitStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_dq_init.fits', output_hdus=[], id='dq_init_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_cal.fits', test_dir='test_extract_1d', step_class=Extract1dStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_spec.fits', output_hdus=[], id='extract1d_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_assign_wcs.fits', test_dir='test_extract_2d', step_class=Extract2dStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_extract_2d.fits', output_hdus=[], id='extract2d_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_extract_2d.fits', test_dir='test_flat_field', step_class=FlatFieldStep, step_pars=dict(save_interpolated_flat=True), output_truth='jw00023001001_01101_00001_NRS1_flat_field.fits', output_hdus=[], id='flat_field_nirspec' ), dict(input='NRSIRS2_230_491_uncal.fits', test_dir='test_group_scale', step_class=GroupScaleStep, step_pars=dict(), output_truth='NRSIRS2_230_491_groupscale.fits', output_hdus=[], id='group_scale_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_linearity.fits', test_dir='test_jump', step_class=JumpStep, step_pars=dict(rejection_threshold=50.0), output_truth='jw00023001001_01101_00001_NRS1_jump.fits', output_hdus=[], id='jump_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_dark_current.fits', test_dir='test_linearity', step_class=LinearityStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_linearity.fits', output_hdus=[], id='linearity_nirspec' ), dict(input='jw00023001001_01101_00001_NRS1_flat_field.fits', test_dir='test_photom', step_class=PhotomStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_photom.fits', output_hdus=[], id='photom_nirspec' ), dict(input='jw84600007001_02101_00001_nrs1_superbias.fits', test_dir='test_bias_drift', step_class=RefPixStep, step_pars=dict(), output_truth='jw84600007001_02101_00001_nrs1_refpix.fits', output_hdus=[], id='refpix_nirspec_irs2' ), dict(input='jw00023001001_01101_00001_NRS1_bias_drift.fits', test_dir='test_saturation', step_class=SaturationStep, step_pars=dict(), output_truth='jw00023001001_01101_00001_NRS1_saturation.fits', output_hdus=[], id='saturation_nirspec' ), dict(input='jw00011001001_01106_00001_NRS2_saturation.fits', test_dir='test_superbias', step_class=SuperBiasStep, step_pars=dict(), output_truth='jw00011001001_01106_00001_NRS2_superbias.fits', output_hdus=[], id='superbias_nirspec' ) ] }
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,500
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/associations/test_main.py
"""test_associations: Test of general Association functionality.""" import re import pytest from jwst.associations.main import Main @pytest.mark.skip( reason='Takes too long and is not currently contributing to any actual testing' ) @pytest.mark.slow def test_script(full_pool_rules): """Test full run of the script code""" pool, rules, pool_fname = full_pool_rules ref_rule_set = { 'candidate_Asn_Coron', 'discover_Asn_TSO', 'candidate_Asn_Lv2NRSFSS', 'candidate_Asn_SpectralTarget', 'candidate_Asn_TSO', 'candidate_Asn_WFSCMB', 'candidate_Asn_Lv2SpecSpecial', 'candidate_Asn_Image', 'candidate_Asn_IFU', 'candidate_Asn_Lv2NRSMSA', 'candidate_Asn_Lv2Image', 'candidate_Asn_Lv2Spec', 'discover_Asn_AMI', 'candidate_Asn_AMI', 'candidate_Asn_Lv2ImageSpecial', 'candidate_Asn_Lv2SpecTSO', 'candidate_Asn_SpectralSource', 'candidate_Asn_Lv2WFSS', 'discover_Asn_Coron', 'candidate_Asn_WFSS_NIS', 'discover_Asn_IFU', 'candidate_Asn_Lv2WFSC', 'candidate_Asn_Lv2ImageNonScience', 'discover_Asn_SpectralTarget', 'candidate_Asn_Lv2ImageTSO', 'discover_Asn_SpectralSource', 'discover_Asn_Image', 'candidate_Asn_Lv2FGS', 'candidate_Asn_Lv3SpecAux' } generated = Main([pool_fname, '--dry-run']) asns = generated.associations assert len(asns) == 938 assert len(generated.orphaned) == 61 found_rules = set( asn['asn_rule'] for asn in asns ) assert ref_rule_set == found_rules @pytest.mark.slow def test_asn_candidates(full_pool_rules): """Test basic candidate selection""" pool, rules, pool_fname = full_pool_rules generated = Main([pool_fname, '--dry-run', '-i', 'o001']) assert len(generated.associations) == 12 generated = Main([pool_fname, '--dry-run', '-i', 'o001', 'o002']) assert len(generated.associations) == 24 @pytest.mark.slow def test_version_id(full_pool_rules): """Test that version id is properly included""" pool, rules, pool_fname = full_pool_rules generated = Main([pool_fname, '--dry-run', '-i', 'o001', '--version-id']) regex = re.compile(r'\d{3}t\d{6}') for asn in generated.associations: assert regex.search(asn.asn_name) version_id = 'mytestid' generated = Main([pool_fname, '--dry-run', '-i', 'o001', '--version-id', version_id]) for asn in generated.associations: assert version_id in asn.asn_name @pytest.mark.slow def test_pool_as_parameter(full_pool_rules): """Test passing the pool as an object""" pool, rules, pool_fname = full_pool_rules full = Main([pool_fname, '--dry-run']) full_as_param = Main(['--dry-run'], pool=pool) assert len(full.associations) == len(full_as_param.associations)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,501
mperrin/jwst
refs/heads/master
/jwst/datamodels/tests/test_open.py
""" Test datamodel.open """ import os import os.path import warnings import pytest import numpy as np from astropy.io import fits from jwst.datamodels import (DataModel, ModelContainer, ImageModel, ReferenceFileModel, ReferenceImageModel, ReferenceCubeModel, ReferenceQuadModel, FlatModel, MaskModel, NrcImgPhotomModel, GainModel, ReadnoiseModel, DistortionModel) from jwst import datamodels def test_open_fits(): """Test opening a model from a FITS file""" with warnings.catch_warnings(): warnings.filterwarnings("ignore", "model_type not found") fits_file = t_path('test.fits') with datamodels.open(fits_file) as model: assert isinstance(model, DataModel) def test_open_fits_s3(s3_root_dir): """Test opening a model from a FITS file on S3""" path = str(s3_root_dir.join("test.fits")) with DataModel() as dm: dm.save(path) with datamodels.open("s3://test-s3-data/test.fits") as m: assert isinstance(m, DataModel) def test_open_asdf_s3(s3_root_dir): """Test opening a model from an ASDF file on S3""" path = str(s3_root_dir.join("test.asdf")) with DataModel() as dm: dm.save(path) with datamodels.open("s3://test-s3-data/test.asdf") as m: assert isinstance(m, DataModel) def test_open_association(): """Test for opening an association""" asn_file = t_path('association.json') with warnings.catch_warnings(): warnings.filterwarnings("ignore", "model_type not found") with datamodels.open(asn_file) as c: assert isinstance(c, ModelContainer) for model in c: assert model.meta.asn.table_name == "association.json" assert model.meta.asn.pool_name == "pool" def test_container_open_asn_with_sourcecat(): path = t_path("association_w_cat.json") with datamodels.open(path, asn_exptypes="science") as c: for model in c: assert model.meta.asn.table_name == "association_w_cat.json" def test_open_shape(): init = (200, 200) with datamodels.open(init) as model: assert type(model) == ImageModel def test_open_illegal(): with pytest.raises(ValueError): init = 5 datamodels.open(init) def test_open_hdulist(): hdulist = fits.HDUList() data = np.empty((50, 50), dtype=np.float32) primary = fits.PrimaryHDU() hdulist.append(primary) science = fits.ImageHDU(data=data, name='SCI') hdulist.append(science) with datamodels.open(hdulist) as model: assert type(model) == ImageModel def test_open_image(): with warnings.catch_warnings(): warnings.filterwarnings("ignore", "model_type not found") image_name = t_path('jwst_image.fits') with datamodels.open(image_name) as model: assert type(model) == ImageModel def test_open_reference_files(): files = {'nircam_flat.fits' : FlatModel, 'nircam_mask.fits' : MaskModel, 'nircam_photom.fits' : NrcImgPhotomModel, 'nircam_gain.fits' : GainModel, 'nircam_readnoise.fits' : ReadnoiseModel} with warnings.catch_warnings(): warnings.filterwarnings("ignore", "model_type not found") for base_name, klass in files.items(): file = t_path(base_name) model = datamodels.open(file) if model.shape: ndim = len(model.shape) else: ndim = 0 if ndim == 0: my_klass = ReferenceFileModel elif ndim == 2: my_klass = ReferenceImageModel elif ndim == 3: my_klass = ReferenceCubeModel elif ndim == 4: my_klass = ReferenceQuadModel else: my_klass = None assert isinstance(model, my_klass) model.close() model = klass(file) assert isinstance(model, klass) model.close() def test_open_fits_readonly(tmpdir): """Test opening a FITS-format datamodel that is read-only on disk""" tmpfile = str(tmpdir.join('readonly.fits')) data = np.arange(100, dtype=np.float).reshape(10, 10) with ImageModel(data=data) as model: model.meta.telescope = 'JWST' model.meta.instrument.name = 'NIRCAM' model.meta.instrument.detector = 'NRCA4' model.meta.instrument.channel = 'SHORT' model.save(tmpfile) os.chmod(tmpfile, 0o440) assert os.access(tmpfile, os.W_OK) == False with datamodels.open(tmpfile) as model: assert model.meta.telescope == 'JWST' def test_open_asdf_readonly(tmpdir): tmpfile = str(tmpdir.join('readonly.asdf')) with DistortionModel() as model: model.meta.telescope = 'JWST' model.meta.instrument.name = 'NIRCAM' model.meta.instrument.detector = 'NRCA4' model.meta.instrument.channel = 'SHORT' model.save(tmpfile) os.chmod(tmpfile, 0o440) assert os.access(tmpfile, os.W_OK) == False with datamodels.open(tmpfile) as model: assert model.meta.telescope == 'JWST' # Utilities def t_path(partial_path): """Construction the full path for test files""" test_dir = os.path.join(os.path.dirname(__file__), 'data') return os.path.join(test_dir, partial_path)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,502
mperrin/jwst
refs/heads/master
/jwst/pipeline/linear_pipeline.py
# # Simple linear pipeline from ..stpipe import LinearPipeline from ..ipc.ipc_step import IPCStep from ..dq_init.dq_init_step import DQInitStep from ..refpix.refpix_step import RefPixStep from ..saturation.saturation_step import SaturationStep from ..dark_current.dark_current_step import DarkCurrentStep from ..linearity.linearity_step import LinearityStep from ..jump.jump_step import JumpStep from ..ramp_fitting.ramp_fit_step import RampFitStep from ..assign_wcs.assign_wcs_step import AssignWcsStep from ..extract_2d.extract_2d_step import Extract2dStep from ..flatfield.flat_field_step import FlatFieldStep from ..persistence.persistence_step import PersistenceStep from ..straylight.straylight_step import StraylightStep from ..fringe.fringe_step import FringeStep from ..photom.photom_step import PhotomStep class TestLinearPipeline(LinearPipeline): pipeline_steps = [ ('ipc', IPCStep), ('dq_init', DQInitStep), ('refpix', RefPixStep), ('saturation', SaturationStep), ('dark_current', DarkCurrentStep), ('linearity', LinearityStep), ('jump', JumpStep), ('ramp_fit', RampFitStep), ('assign_wcs', AssignWcsStep), ('extract_2d', Extract2dStep), ('flat_field', FlatFieldStep), ('persistence', PersistenceStep), ('straylight', StraylightStep), ('fringe', FringeStep), ('photom', PhotomStep) ]
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,503
mperrin/jwst
refs/heads/master
/jwst/stpipe/utilities.py
# Copyright (C) 2010 Association of Universities for Research in Astronomy(AURA) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # # 3. The name of AURA and its representatives may not be used to # endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. """ Utilities """ import inspect import os import sys def import_class(full_name, subclassof=object, config_file=None): """ Import the Python class `full_name` given in full Python package format, e.g.:: package.another_package.class_name Return the imported class. Optionally, if `subclassof` is not None and is a Python class, make sure that the imported class is a subclass of `subclassof`. """ # Understand which class we need to instantiate. The class name is given in # full Python package notation, e.g. # package.subPackage.subsubpackage.className # in the input parameter `full_name`. This means that # 1. We HAVE to be able to say # from package.subPackage.subsubpackage import className # 2. If `subclassof` is defined, the newly imported Python class MUST be a # subclass of `subclassof`, which HAS to be a Python class. if config_file is not None: sys.path.insert(0, os.path.dirname(config_file)) try: full_name = full_name.strip() package_name, sep, class_name = full_name.rpartition('.') if not package_name: raise ImportError("{0} is not a Python class".format(full_name)) imported = __import__( package_name, globals(), locals(), [class_name, ], level=0) step_class = getattr(imported, class_name) if not isinstance(step_class, type): raise TypeError( 'Object {0} from package {1} is not a class'.format( class_name, package_name)) elif not issubclass(step_class, subclassof): raise TypeError( 'Class {0} from package {1} is not a subclass of {2}'.format( class_name, package_name, subclassof.__name__)) finally: if config_file is not None: del sys.path[0] return step_class def get_spec_file_path(step_class): """ Given a Step (sub)class, divine and return the full path to the corresponding spec file. Use the fact that by convention, the spec file is in the same directory as the `step_class` source file. It has the name of the Step (sub)class and extension .spec. """ try: step_source_file = inspect.getfile(step_class) except TypeError: return None step_source_file = os.path.abspath(step_source_file) # Since `step_class` could be defined in a file called whatever, # we need the source file basedir and the class name. dir = os.path.dirname(step_source_file) return os.path.join(dir, step_class.__name__ + '.spec') def find_spec_file(step_class): """ Return the full path of the given Step subclass `step_class`, if it exists or None if it does not. """ spec_file = get_spec_file_path(step_class) if spec_file is not None and os.path.exists(spec_file): return spec_file return None def islist_tuple(obj): """ Return True if `obj` is either a list or a tuple. False otherwise. """ return isinstance(obj, tuple) or isinstance(obj, list)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,504
mperrin/jwst
refs/heads/master
/jwst/stpipe/linear_pipeline.py
# Copyright (C) 2010 Association of Universities for Research in Astronomy(AURA) # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # # 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # # 3. The name of AURA and its representatives may not be used to # endorse or promote products derived from this software without # specific prior written permission. # # THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. """ LinearPipeline """ import gc from .pipeline import Pipeline class _LinearPipelineMetaclass(type): def __init__(cls, name, bases, dct): super(_LinearPipelineMetaclass, cls).__init__(name, bases, dct) pipeline_steps = cls.pipeline_steps if pipeline_steps is not None and len(pipeline_steps) == 0: raise ValueError( "{0!r} LinearPipeline subclass defines no pipeline_steps" .format(name)) if pipeline_steps is None: pipeline_steps = [] cls.step_defs = dict(pipeline_steps) # Since the pipeline_steps member needs to be converted to a step_defs # at the class level, we need to use a metaclass. class LinearPipeline(Pipeline, metaclass=_LinearPipelineMetaclass): """ A LinearPipeline is a way of combining a number of steps together in a simple linear order. """ spec = """ # start_step and end_step allow only a part of the pipeline to run start_step = string(default=None) # Start the pipeline at this step end_step = string(default=None) # End the pipeline right before this step # [steps] section is implicitly added by the Pipeline class. """ # To be overridden by subclasses pipeline_steps = None def _check_start_and_end_steps(self): """ Given the start_step and end_step members (which are strings or None), find the actual step objects they correspond to. """ start_step = end_step = None if self.start_step is not None: if hasattr(self, self.start_step): start_step = getattr(self, self.start_step) else: raise ValueError( "start_step {0!r} not found".format( self.start_step)) if self.end_step is not None: if hasattr(self, self.end_step): end_step = getattr(self, self.end_step) else: raise ValueError( "end_step {0!r} not found".format( self.end_step)) return start_step, end_step def process(self, input_file): """ Run the pipeline. """ self._check_start_and_end_steps() do_caching = ( self.end_step is not None and self.end_step != self.pipeline_steps[-1][0]) if self.start_step is None: mode = 'RUN' else: mode = 'BEFORE' # It would be easiest to do this in a loop, # but we use recursion instead to make the "with" statements # work correctly def recurse(mode, input_file, pipeline_steps): gc.collect() if pipeline_steps == []: if (hasattr(self, 'output_file') and self.output_file is not None): input_file.save(self.output_file) return input_file name, cls = pipeline_steps[0] step = getattr(self, name) filename = '{0}.fits'.format(self.qualified_name) if name == self.start_step: mode = 'RUN' if mode == 'BEFORE': from .. import datamodels try: with datamodels.open(filename) as dm: pass except (ValueError, TypeError, IOError): return recurse(mode, filename, pipeline_steps[1:]) else: dm = datamodels.open(filename) return recurse(mode, dm, pipeline_steps[1:]) elif mode == 'RUN': dm = step(input_file) if do_caching: dm.save(filename) if name == self.end_step: return None return recurse(mode, dm, pipeline_steps[1:]) result = recurse(mode, input_file, self.pipeline_steps) gc.collect() return result def set_input_filename(self, path): for name, cls in self.pipeline_steps: getattr(self, name).set_input_filename(path)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,505
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py
import os import glob import pytest from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn from ci_watson.artifactory_helpers import get_bigdata from jwst.ramp_fitting import RampFitStep from jwst.wfs_combine import WfsCombineStep from jwst.pipeline import Detector1Pipeline from jwst.lib.set_telescope_pointing import add_wcs from jwst.lib import engdb_tools from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step @pytest.mark.bigdata class TestWFSImage2(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_datasets', 'sdp_jw82600_wfs', 'level2a', 'truth'] test_dir = 'test_datasets' def test_wfs_image2(self): """ Regression test of the WFS&C `calwebb_wfs-image2.cfg` pipeline """ data_base = 'jw82600026001_02101_00001_nrca1_rate' ext = '.fits' input_name = '{}{}'.format(data_base, ext) input_file = self.get_data(self.test_dir, 'sdp_jw82600_wfs', 'level2a', input_name) collect_pipeline_cfgs('cfgs') Step.from_cmdline([os.path.join('cfgs', 'calwebb_wfs-image2.cfg'), input_file]) cal_name = input_name.replace('rate', 'cal') output_name = input_name.replace('rate','cal_ref') outputs = [(cal_name, output_name)] self.compare_outputs(outputs) output_files = glob.glob('*') output_files.remove('cfgs') # these would happen when docopy=True if input_name in output_files: output_files.remove(input_name) if output_name in output_files: output_files.remove(output_name) if "truth" in output_files: output_files.remove("truth") assert cal_name in output_files output_files.remove(cal_name) assert not output_files, 'Unexpected output files {}'.format(output_files) @pytest.mark.bigdata class TestDetector1Pipeline(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_detector1pipeline', 'truth'] test_dir = 'test_detector1pipeline' def test_detector1pipeline3(self): """ Regression test of calwebb_detector1 pipeline performed on NIRCam data. """ input_file = self.get_data(self.test_dir, 'jw82500001003_02101_00001_NRCALONG_uncal.fits') step = Detector1Pipeline() step.save_calibrated_ramp = True step.ipc.skip = True step.refpix.odd_even_columns = True step.refpix.use_side_ref_pixels = False step.refpix.side_smoothing_length = 10 step.refpix.side_gain = 1.0 step.persistence.skip = True step.jump.rejection_threshold = 250.0 step.ramp_fit.save_opt = True step.output_file = 'jw82500001003_02101_00001_NRCALONG_rate.fits' step.run(input_file) outputs = [('jw82500001003_02101_00001_NRCALONG_ramp.fits', 'jw82500001003_02101_00001_NRCALONG_ramp_ref.fits'), ('jw82500001003_02101_00001_NRCALONG_rate.fits', 'jw82500001003_02101_00001_NRCALONG_rate_ref.fits'), ('jw82500001003_02101_00001_NRCALONG_rateints.fits', 'jw82500001003_02101_00001_NRCALONG_rateints_ref.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRCamRamp(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_ramp_fit', 'truth'] test_dir = 'test_ramp_fit' def test_ramp_fit_nircam(self): """ Regression test of ramp_fit step performed on NIRCam data. """ input_file = self.get_data(self.test_dir, 'jw00017001001_01101_00001_NRCA1_jump.fits') result, result_int = RampFitStep.call(input_file, save_opt=True, opt_name='rampfit_opt_out.fits' ) optout_file = 'rampfit_opt_out_fitopt.fits' output_file = result.meta.filename result.save(output_file) result.close() outputs = [(output_file, 'jw00017001001_01101_00001_NRCA1_ramp_fit.fits'), (optout_file, 'rampfit_opt_out.fits', ['primary','slope','sigslope','yint','sigyint','pedestal','weights','crmag']) ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestWFSCombine(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_wfs_combine', 'truth'] test_dir = 'test_wfs_combine' def test_wfs_combine(self): """ Regression test of wfs_combine using do_refine=False (default) Association table has 3 (identical) pairs of input files to combine """ asn_file = self.get_data(self.test_dir, 'wfs_3sets_asn.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) WfsCombineStep.call(asn_file) outputs = [('test_wfscom_wfscmb.fits', 'test_wfscom.fits'), ('test_wfscoma_wfscmb.fits', 'test_wfscoma.fits'), ('test_wfscomb_wfscmb.fits', 'test_wfscomb.fits') ] self.compare_outputs(outputs) def test_wfs_combine1(self): """ Regression test of wfs_combine using do_refine=True """ asn_file = self.get_data(self.test_dir, 'wfs_3sets_asn2.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) WfsCombineStep.call(asn_file, do_refine=True ) outputs = [('test_wfscom2_wfscmb.fits', 'test_wfscom_do_ref.fits'), ('test_wfscom2a_wfscmb.fits', 'test_wfscoma_do_ref.fits'), ('test_wfscom2b_wfscmb.fits', 'test_wfscomb_do_ref.fits') ] self.compare_outputs(outputs) def test_wfs_combine2(self): """ Regression test of wfs_combine using do_refine=True """ asn_file = self.get_data(self.test_dir, 'wfs_3sets_asn3.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) WfsCombineStep.call(asn_file, do_refine=True) outputs = [('test_wfscom3_wfscmb.fits', 'test_wfscom_do_ref.fits'), ('test_wfscom3a_wfscmb.fits', 'test_wfscoma_do_ref.fits'), ('test_wfscom3b_wfscmb.fits', 'test_wfscomb_do_ref.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNrcGrismSetPointing(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_pointing', 'truth'] test_dir = 'test_pointing' rtol = 0.000001 def test_nircam_setpointing(self): """ Regression test of the set_telescope_pointing script on a level-1b NIRCam file. """ # Copy original version of file to test file, which will get overwritten by test input_file = self.get_data(self.test_dir, 'jw00721012001_03103_00001-seg001_nrcalong_uncal_orig.fits') # Get SIAF PRD database file siaf_prd_loc = ['jwst-pipeline', self.env, 'common', 'prd.db'] siaf_path = get_bigdata(*siaf_prd_loc) # Call the WCS routine, using the ENGDB_Service add_wcs(input_file, siaf_path=siaf_path, engdb_url=engdb_tools.ENGDB_BASE_URL) outputs = [(input_file, 'jw00721012001_03103_00001-seg001_nrcalong_uncal_ref.fits')] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,506
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py
import pytest from jwst.pipeline.calwebb_detector1 import Detector1Pipeline from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.skip @pytest.mark.bigdata class TestSloperPipeline(BaseJWSTTest): input_loc = 'fgs' ref_loc = ['test_sloperpipeline', 'truth'] def test_fgs_detector1_1(self): """ Regression test of calwebb_detector1 pipeline performed on FGS imaging mode data. """ input_file = self.get_data('test_sloperpipeline', 'jw86500007001_02101_00001_GUIDER2_uncal.fits') pipe = Detector1Pipeline() pipe.ipc.skip = True pipe.refpix.odd_even_columns = True pipe.refpix.use_side_ref_pixels = True pipe.refpix.side_smoothing_length = 11 pipe.refpix.side_gain = 1.0 pipe.refpix.odd_even_rows = True pipe.jump.rejection_threshold = 250.0 pipe.persistence.skip = True pipe.ramp_fit.save_opt = False pipe.save_calibrated_ramp = True pipe.output_file = 'jw86500007001_02101_00001_GUIDER2_rate.fits' pipe.run(input_file) outputs = [('jw86500007001_02101_00001_GUIDER2_ramp.fits', 'jw86500007001_02101_00001_GUIDER2_ramp_ref.fits', ['primary','sci','err','groupdq','pixeldq']), ('jw86500007001_02101_00001_GUIDER2_rateints.fits', 'jw86500007001_02101_00001_GUIDER2_rateints_ref.fits', ['primary','sci','err','dq']), ('jw86500007001_02101_00001_GUIDER2_rate.fits', 'jw86500007001_02101_00001_GUIDER2_rate_ref.fits', ['primary','sci','err','dq']) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,507
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_nrs_ifu_wcs.py
import pytest from numpy.testing import assert_allclose from gwcs.wcstools import grid_from_bounding_box from ci_watson.artifactory_helpers import get_bigdata from jwst.assign_wcs import AssignWcsStep, nirspec from jwst.datamodels import ImageModel testdata = [ ('nrs1', 'jw00011001001_01120_00001_NRS1_rate.fits', 'jw00011001001_01120_00001_NRS1_assign_wcs.fits'), ('nrs1_opaque', 'jw00011001001_01120_00001_NRS1_rate_opaque.fits', 'jw00011001001_01120_00001_NRS1_rate_opaque_assign_wcs.fits'), ('nrs2', 'NRSIFU-COMBO-030_NRS2_SloperPipeline.fits', 'NRSIFU-COMBO-030_NRS2_SloperPipeline_assign_wcs.fits') ] @pytest.mark.bigdata @pytest.mark.parametrize("test_id, input_file, truth_file", testdata) def test_nirspec_ifu_wcs(envopt, _jail, test_id, input_file, truth_file): """ Regression test of creating a WCS object and doing pixel to sky transformation. """ del test_id input_file = get_bigdata('jwst-pipeline', envopt, 'nirspec', 'test_wcs', 'nrs1-ifu', input_file) truth_file = get_bigdata('jwst-pipeline', envopt, 'nirspec', 'test_wcs', 'nrs1-ifu', 'truth', truth_file) result = AssignWcsStep.call(input_file, save_results=True, suffix='assign_wcs') result.close() im = ImageModel(result.meta.filename) imref = ImageModel(truth_file) w = nirspec.nrs_wcs_set_input(im, 0) grid = grid_from_bounding_box(w.bounding_box) ra, dec, lam = w(*grid) wref = nirspec.nrs_wcs_set_input(imref, 0) raref, decref, lamref = wref(*grid) # equal_nan is used here as many of the entries are nan. # The domain is defined but it is only a few entries in there that are valid # as it is a curved narrow slit. assert_allclose(ra, raref, equal_nan=True) assert_allclose(dec, decref, equal_nan=True) assert_allclose(lam, lamref, equal_nan=True)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,508
mperrin/jwst
refs/heads/master
/jwst/lib/s3_utils.py
""" Experimental support for reading reference files from S3. Use of these functions requires installing the [aws] extras (but this module can be safely imported without them). """ import atexit __all__ = ["object_exists", "get_object", "get_client", "is_s3_uri", "split_uri"] _CLIENT = None def object_exists(uri): """ Determine if an object exists on S3. Parameters ---------- uri : str S3 URI (s3://bucket-name/some/key) Returns ------- bool `True` if object exists, `False` if not. """ bucket_name, key = split_uri(uri) return get_client().object_exists(bucket_name, key) def get_object(uri): """ Fetch the content of an object from S3. Parameters ---------- uri : str S3 URI (s3://bucket-name/some/key) Returns ------- io.BytesIO The content of the object. """ bucket_name, key = split_uri(uri) return get_client().get_object(bucket_name, key) def get_client(): """ Get the shared instance of ConcurrentS3Client. Returns ------- stsci_aws_utils.s3.ConcurrentS3Client """ global _CLIENT if _CLIENT is None: from stsci_aws_utils.s3 import ConcurrentS3Client _CLIENT = ConcurrentS3Client() atexit.register(_CLIENT.close) return _CLIENT def is_s3_uri(value): """ Determine if a value represents an S3 URI. Parameters ---------- value : str Value to test. Returns ------- bool `True` if value is an S3 URI, `False` if not. """ return value.startswith("s3://") def split_uri(uri): """ Split an S3 URI into bucket name and key components. Parameters ---------- uri : str S3 URI (s3://bucket-name/some/key) Returns ------- str Bucket name URI component str Key URI component """ if not uri.startswith("s3://"): raise ValueError("Expected S3 URI") bucket_name, key = uri.replace("s3://", "").split("/", 1) return bucket_name, key
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,509
mperrin/jwst
refs/heads/master
/jwst/regtest/test_fgs_guider.py
"""Regression tests for FGS Guidestar in ID and FINEGUIDE modes""" import os import pytest from astropy.io.fits.diff import FITSDiff from jwst.lib.suffix import replace_suffix from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step def is_like_truth(rtdata, fitsdiff_default_kwargs, suffix, truth_path='truth/fgs/test_fgs_guider'): """Compare step outputs with truth""" output = replace_suffix( os.path.splitext(os.path.basename(rtdata.input))[0], suffix ) + '.fits' rtdata.output = output rtdata.get_truth(os.path.join(truth_path, output)) diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report() file_roots = ['exptype_fgs_acq1', 'exptype_fgs_fineguide', 'exptype_fgs_id_image', 'exptype_fgs_id_stack'] @pytest.fixture(scope='module', params=file_roots, ids=file_roots) def run_guider_pipelines(jail, rtdata_module, request): """Run pipeline for guider data""" rtdata = rtdata_module rtdata.get_data('fgs/level1b/' + request.param + '_uncal.fits') collect_pipeline_cfgs('config') args = [ 'config/calwebb_guider.cfg', rtdata.input, '--steps.dq_init.save_results=true', '--steps.guider_cds.save_results=true', ] Step.from_cmdline(args) return rtdata guider_suffixes = ['cal', 'dq_init', 'guider_cds'] @pytest.mark.bigdata @pytest.mark.parametrize('suffix', guider_suffixes, ids=guider_suffixes) def test_fgs_guider(run_guider_pipelines, fitsdiff_default_kwargs, suffix): """Regression for FGS Guider data""" is_like_truth(run_guider_pipelines, fitsdiff_default_kwargs, suffix)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,510
mperrin/jwst
refs/heads/master
/jwst/regtest/test_miri_mrs.py
"""Regression tests for MIRI MRS modes""" from pathlib import Path import pytest from numpy.testing import assert_allclose from jwst.associations import load_asn from jwst.lib.suffix import replace_suffix from jwst import datamodels from gwcs.wcstools import grid_from_bounding_box from . import regtestdata as rt # Define artifactory source and truth INPUT_PATH = 'miri/mrs' TRUTH_PATH = 'truth/test_miri_mrs' @pytest.fixture(scope='module') def run_spec2(jail, rtdata_module): """Run the Spec2Pipeline on a single exposure""" rtdata = rtdata_module # Setup the inputs asn_name = 'ifushort_ch12_rate_asn3.json' rtdata.get_data(INPUT_PATH + '/' + asn_name) asn_path = rtdata.input with open(asn_path, 'r') as asn_fh: asn = load_asn(asn_fh) member_path = Path(asn['products'][0]['members'][0]['expname']) rate_path = member_path.stem rate_path = replace_suffix(rate_path, 'rate') rate_path = INPUT_PATH + '/' + rate_path + member_path.suffix # Run the pipeline step_params = { 'input_path': rate_path, 'step': 'calwebb_spec2.cfg', 'args': [ '--steps.bkg_subtract.save_results=true', '--steps.assign_wcs.save_results=true', '--steps.imprint_subtract.save_results=true', '--steps.msa_flagging.save_results=true', '--steps.extract_2d.save_results=true', '--steps.flat_field.save_results=true', '--steps.srctype.save_results=true', '--steps.straylight.save_results=true', '--steps.fringe.save_results=true', '--steps.pathloss.save_results=true', '--steps.barshadow.save_results=true', '--steps.photom.save_results=true', '--steps.resample_spec.save_results=true', '--steps.cube_build.save_results=true', '--steps.extract_1d.save_results=true', ] } rtdata = rt.run_step_from_dict(rtdata, **step_params) return rtdata, asn_path @pytest.fixture(scope='module') def run_spec3(jail, run_spec2): """Run the Spec3Pipeline on the results from the Spec2Pipeline run""" rtdata, asn_path = run_spec2 # The presumption is that `run_spec2` has set the input to the # original association. To use this default, and not re-download # the association, simply do not specify `step_params["input_path"]` rtdata.input = asn_path step_params = { 'step': 'calwebb_spec3.cfg', 'args': [ '--steps.master_background.save_results=true', '--steps.mrs_imatch.save_results=true', '--steps.outlier_detection.save_results=true', '--steps.resample_spec.save_results=true', '--steps.cube_build.save_results=true', '--steps.extract_1d.save_results=true', '--steps.combine_1d.save_results=true', ] } return rt.run_step_from_dict(rtdata, **step_params) @pytest.fixture(scope='module') def run_spec3_multi(jail, rtdata_module): """Run the Spec3Pipeline on multi channel/multi filter data""" step_params = { 'input_path': INPUT_PATH + '/' + 'ifushort_set2_asn3.json', 'step': 'calwebb_spec3.cfg', 'args': [ '--steps.master_background.save_results=true', '--steps.mrs_imatch.save_results=true', '--steps.outlier_detection.save_results=true', '--steps.resample_spec.save_results=true', '--steps.cube_build.save_results=true', '--steps.extract_1d.save_results=true', '--steps.combine_1d.save_results=true', ] } return rt.run_step_from_dict(rtdata_module, **step_params) @pytest.mark.bigdata @pytest.mark.parametrize( 'suffix', ['assign_wcs', 'cal', 'flat_field', 'fringe', 'photom', 's3d', 'srctype', 'straylight', 'x1d'] ) def test_spec2(run_spec2, fitsdiff_default_kwargs, suffix): """Test ensuring the callwebb_spec2 is operating appropriately for MIRI MRS data""" rtdata, asn_path = run_spec2 rt.is_like_truth(rtdata, fitsdiff_default_kwargs, suffix, truth_path=TRUTH_PATH) @pytest.mark.bigdata @pytest.mark.parametrize( 'output', [ 'ifushort_ch12_spec3_mrs_imatch.fits', 'ifushort_ch12_spec3_ch1-medium_s3d.fits', 'ifushort_ch12_spec3_ch2-medium_s3d.fits', 'ifushort_ch12_spec3_ch1-medium_x1d.fits', 'ifushort_ch12_spec3_ch2-medium_x1d.fits', ], ids=["mrs_imatch", "ch1-s3d", "ch2-s3d", "ch1-x1d", "ch2-x1d"] ) def test_spec3(run_spec3, fitsdiff_default_kwargs, output): """Regression test matching output files""" rt.is_like_truth( run_spec3, fitsdiff_default_kwargs, output, truth_path=TRUTH_PATH, is_suffix=False ) @pytest.mark.bigdata @pytest.mark.parametrize( 'output', [ 'ifushort_set2_0_mrs_imatch.fits', 'ifushort_set2_1_mrs_imatch.fits', 'ifushort_set2_0_a3001_crf.fits', 'ifushort_set2_1_a3001_crf.fits', 'ifushort_set2_ch1-short_s3d.fits', 'ifushort_set2_ch2-short_s3d.fits', 'ifushort_set2_ch1-short_x1d.fits', 'ifushort_set2_ch2-short_x1d.fits', ], ids=["ch1-mrs_imatch", "ch2-mrs_imatch", "ch1-crf", "ch2-crf", "ch1-s3d", "ch2-s3d", "ch1-x1d", "ch2-x1d"] ) def test_spec3_multi(run_spec3_multi, fitsdiff_default_kwargs, output): """Regression test matching output files""" rt.is_like_truth( run_spec3_multi, fitsdiff_default_kwargs, output, truth_path=TRUTH_PATH, is_suffix=False ) @pytest.mark.bigdata def test_miri_mrs_wcs(run_spec2, fitsdiff_default_kwargs): rtdata, asn_path = run_spec2 # get input assign_wcs and truth file output = "ifushort_ch12_assign_wcs.fits" rtdata.output = output rtdata.get_truth(f"truth/test_miri_mrs/{output}") # Open the output and truth file with datamodels.open(rtdata.output) as im, datamodels.open(rtdata.truth) as im_truth: x, y = grid_from_bounding_box(im.meta.wcs.bounding_box) ra, dec, lam = im.meta.wcs(x, y) ratruth, dectruth, lamtruth = im_truth.meta.wcs(x, y) assert_allclose(ra, ratruth) assert_allclose(dec, dectruth) assert_allclose(lam, lamtruth) # Test the inverse transform xtest, ytest = im.meta.wcs.backward_transform(ra, dec, lam) xtruth, ytruth = im_truth.meta.wcs.backward_transform(ratruth, dectruth, lamtruth) assert_allclose(xtest, xtruth) assert_allclose(ytest, ytruth)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,511
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py
import pytest from jwst.pipeline import Spec2Pipeline from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestSpec2Pipeline(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_spec2pipeline', 'truth'] test_dir = 'test_spec2pipeline' def test_miri_lrs_bkgnod(self): """ Regression test of calwebb_spec2 pipeline performed on an association of nodded MIRI LRS fixed-slit exposures. """ asn_file = self.get_data(self.test_dir, 'lrs_bkgnod_asn.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) step = Spec2Pipeline() step.save_bsub=True step.save_results=True step.resample_spec.save_results = True step.cube_build.save_results = True step.extract_1d.save_results = True step.run(asn_file) outputs = [('test_lrs1_bsub.fits', 'test_lrs1_bsub_ref.fits', ['primary','sci','err','dq']), ('test_lrs2_bsub.fits','test_lrs2_bsub_ref.fits', ['primary','sci','err','dq']), ('test_lrs3_bsub.fits','test_lrs3_bsub_ref.fits', ['primary','sci','err','dq']), ('test_lrs4_bsub.fits','test_lrs4_bsub_ref.fits', ['primary','sci','err','dq']), ('test_lrs1_cal.fits', 'test_lrs1_cal_ref.fits', ['primary','sci','err','dq']), ('test_lrs2_cal.fits', 'test_lrs2_cal_ref.fits', ['primary','sci','err','dq']), ('test_lrs3_cal.fits', 'test_lrs3_cal_ref.fits', ['primary','sci','err','dq']), ('test_lrs4_cal.fits', 'test_lrs4_cal_ref.fits', ['primary','sci','err','dq']) ] self.compare_outputs(outputs) def test_miri_lrs_slit_1(self): """ Regression test of calwebb_spec2 pipeline performed on a single MIRI LRS fixed-slit exposure. """ input_file = self.get_data(self.test_dir, 'jw00035001001_01101_00001_MIRIMAGE_rate.fits') step = Spec2Pipeline() step.save_bsub=True step.save_results=True step.resample_spec.save_results = True step.cube_build.save_results = True step.extract_1d.save_results = True step.run(input_file) outputs = [('jw00035001001_01101_00001_MIRIMAGE_cal.fits', 'jw00035001001_01101_00001_MIRIMAGE_cal_ref.fits', ['primary','sci','err','dq']), ('jw00035001001_01101_00001_MIRIMAGE_x1d.fits', 'jw00035001001_01101_00001_MIRIMAGE_x1d_ref.fits', ['primary','extract1d']) ] self.compare_outputs(outputs) def test_miri_lrs_slit_1b(self): """ Regression test of calwebb_spec2 pipeline performed on a single MIRI LRS fixed-slit exposure with multiple integrations. Compare _calints. """ input_file = self.get_data(self.test_dir, 'jw00035001001_01101_00001_MIRIMAGE_rateints.fits') step = Spec2Pipeline() step.save_bsub=True step.save_results=True step.extract_1d.save_results = True step.run(input_file) outputs = [('jw00035001001_01101_00001_MIRIMAGE_calints.fits', 'jw00035001001_01101_00001_MIRIMAGE_calints_ref.fits', ['primary','sci','err','dq']), ('jw00035001001_01101_00001_MIRIMAGE_x1dints.fits', 'jw00035001001_01101_00001_MIRIMAGE_x1dints_ref.fits', ['primary', ('extract1d', 1), ('extract1d', 2), ('extract1d', 3), ('extract1d', 4)] ) ] self.compare_outputs(outputs) def test_mrs2pipeline1(self): """ Regression test of calwebb_spec2 pipeline performed on MIRI MRS data. """ test_dir = 'test_mrs2pipeline' self.ref_loc = ['test_mrs2pipeline', 'truth'] input_file = self.get_data(test_dir, 'jw80500018001_02101_00002_MIRIFUSHORT_rate.fits') step = Spec2Pipeline() step.save_bsub=True step.save_results=True step.resample_spec.save_results = True step.cube_build.save_results = True step.extract_1d.save_results = True step.run(input_file) outputs = [('jw80500018001_02101_00002_MIRIFUSHORT_cal.fits', 'jw80500018001_02101_00002_MIRIFUSHORT_cal_ref.fits', ['primary','sci','err','dq']), ('jw80500018001_02101_00002_MIRIFUSHORT_s3d.fits', 'jw80500018001_02101_00002_MIRIFUSHORT_s3d_ref.fits', ['primary','sci','err','dq','wmap']), ('jw80500018001_02101_00002_MIRIFUSHORT_x1d.fits', 'jw80500018001_02101_00002_MIRIFUSHORT_x1d_ref.fits', ['primary','extract1d']) ] self.compare_outputs(outputs) def test_mrs_spec2(self): """ Regression test of calwebb_spec2 pipeline performed on MIRI MRS data. """ self.rtol = 0.000001 input_file = self.get_data(self.test_dir, 'jw10001001001_01101_00001_mirifushort_rate.fits') step = Spec2Pipeline() step.save_bsub=True step.save_results=True step.resample_spec.save_results = True step.cube_build.save_results = True step.extract_1d.save_results = True step.run(input_file) outputs = [('jw10001001001_01101_00001_mirifushort_cal.fits', 'jw10001001001_01101_00001_mirifushort_cal_ref.fits', ['primary','sci','err','dq']), ('jw10001001001_01101_00001_mirifushort_s3d.fits', 'jw10001001001_01101_00001_mirifushort_s3d_ref.fits', ['primary','sci','err','dq','wmap']), ('jw10001001001_01101_00001_mirifushort_x1d.fits', 'jw10001001001_01101_00001_mirifushort_x1d_ref.fits', ['primary','extract1d']) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,512
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/fgs/test_guider_pipeline.py
import pytest from jwst.pipeline.calwebb_guider import GuiderPipeline from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestGuiderPipeline(BaseJWSTTest): input_loc = 'fgs' ref_loc = ['test_guiderpipeline', 'truth'] test_dir = 'test_guiderpipeline' rtol = 0.000001 def test_guider_pipeline1(self): """ Regression test of calwebb_guider pipeline performed on ID-image data. """ input_file = self.get_data(self.test_dir, 'jw88600073001_gs-id_7_image-uncal.fits') GuiderPipeline.call(input_file, output_file='jw88600073001_gs-id_7_image-cal.fits') # Compare calibrated ramp product outputs = [('jw88600073001_gs-id_7_image-cal.fits', 'jw88600073001_gs-id_7_image-cal_ref.fits', ['primary','sci','dq']) ] self.compare_outputs(outputs) def test_guider_pipeline2(self): """ Regression test of calwebb_guider pipeline performed on ACQ-1 data. """ input_file = self.get_data(self.test_dir, 'jw88600073001_gs-acq1_2016022183837_uncal.fits') GuiderPipeline.call(input_file, output_file='jw88600073001_gs-acq1_2016022183837_cal.fits') # Compare calibrated ramp product outputs = [('jw88600073001_gs-acq1_2016022183837_cal.fits', 'jw88600073001_gs-acq1_2016022183837_cal_ref.fits', ['primary','sci','dq']) ] self.compare_outputs(outputs) def test_guider_pipeline3(self): """ Regression test of calwebb_guider pipeline performed on ID STACKED data. """ input_file = self.get_data(self.test_dir, 'jw86600004001_gs-id_1_stacked-uncal.fits') GuiderPipeline.call(input_file, output_file='jw86600004001_gs-id_1_stacked-cal.fits') # Compare calibrated ramp product outputs = [('jw86600004001_gs-id_1_stacked-cal.fits', 'jw86600004001_gs-id_1_stacked-cal_ref.fits', ['primary','sci','dq']) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,513
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_nircam_steps.py
import pytest from jwst.tests.base_classes import BaseJWSTTestSteps from jwst.tests.base_classes import pytest_generate_tests # noqa: F401 from jwst.refpix import RefPixStep from jwst.dark_current import DarkCurrentStep from jwst.dq_init import DQInitStep from jwst.flatfield import FlatFieldStep from jwst.ipc import IPCStep from jwst.jump import JumpStep from jwst.linearity import LinearityStep from jwst.persistence import PersistenceStep from jwst.photom import PhotomStep from jwst.saturation import SaturationStep # Parameterized regression tests for NIRCAM processing # All tests in this set run with 1 input file and # only generate 1 output for comparison. # @pytest.mark.bigdata class TestNIRCamSteps(BaseJWSTTestSteps): input_loc = 'nircam' params = {'test_steps': [dict(input='jw00017001001_01101_00001_NRCA1_dq_init.fits', test_dir='test_bias_drift', step_class=RefPixStep, step_pars=dict(odd_even_columns=True, use_side_ref_pixels=False, side_smoothing_length=10, side_gain=1.0), output_truth='jw00017001001_01101_00001_NRCA1_bias_drift.fits', output_hdus=[], id='refpix_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_saturation.fits', test_dir='test_dark_step', step_class=DarkCurrentStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_dark_current.fits', output_hdus=[], id='dark_current_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_uncal.fits', test_dir='test_dq_init', step_class=DQInitStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_dq_init.fits', output_hdus=[], id='dq_init_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_ramp_fit.fits', test_dir='test_flat_field', step_class=FlatFieldStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_flat_field.fits', output_hdus=[], id='flat_field_nircam' ), dict(input='jw00017001001_01101_00001_NRCA3_uncal.fits', test_dir='test_ipc_step', step_class=IPCStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA3_ipc.fits', output_hdus=['primary', 'sci'], id='ipc_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_linearity.fits', test_dir='test_jump', step_class=JumpStep, step_pars=dict(rejection_threshold=25.0), output_truth='jw00017001001_01101_00001_NRCA1_jump.fits', output_hdus=[], id='jump_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_dark_current.fits', test_dir='test_linearity', step_class=LinearityStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_linearity.fits', output_hdus=[], id='linearity_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_ramp.fits', test_dir='test_persistence', step_class=PersistenceStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_persistence.fits', output_hdus=[], id='persistence_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_emission.fits', test_dir='test_photom', step_class=PhotomStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_photom.fits', output_hdus=[], id='photom_nircam' ), dict(input='jw00017001001_01101_00001_NRCA1_bias_drift.fits', test_dir='test_saturation', step_class=SaturationStep, step_pars=dict(), output_truth='jw00017001001_01101_00001_NRCA1_saturation.fits', output_hdus=[], id='saturation_nircam' ), ] }
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,514
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py
import pytest from jwst.pipeline import Image2Pipeline from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestImage2Pipeline(BaseJWSTTest): input_loc = 'nircam' ref_loc = ['test_image2pipeline', 'truth'] def test_image2pipeline2_cal(self): """ Regression test of calwebb_image2 pipeline performed on NIRCam data. """ input_file = self.get_data('test_image2pipeline', 'jw82500001003_02101_00001_NRCALONG_rate.fits') output_file = 'jw82500001003_02101_00001_NRCALONG_cal.fits' collect_pipeline_cfgs('cfgs') Image2Pipeline.call(input_file, config_file='cfgs/calwebb_image2.cfg', output_file=output_file) outputs = [(output_file, 'jw82500001003_02101_00001_NRCALONG_cal_ref.fits', ['primary','sci','err','dq','area']), ('jw82500001003_02101_00001_NRCALONG_i2d.fits', 'jw82500001003_02101_00001_NRCALONG_i2d_ref.fits', ['primary','sci','con','wht']) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,515
mperrin/jwst
refs/heads/master
/jwst/tests/base_classes.py
from glob import glob as _sys_glob import os from os import path as op from pathlib import Path import sys import pytest import requests from ci_watson.artifactory_helpers import ( BigdataError, check_url, get_bigdata, get_bigdata_root, ) from .compare_outputs import compare_outputs from jwst.associations import load_asn __all__ = [ 'BaseJWSTTest', ] # Define location of default Artifactory API key, for Jenkins use only ARTIFACTORY_API_KEY_FILE = '/eng/ssb2/keys/svc_rodata.key' @pytest.mark.usefixtures('_jail') @pytest.mark.bigdata class BaseJWSTTest: ''' Base test class from which to derive JWST regression tests ''' rtol = 0.00001 atol = 0 input_loc = '' # root directory for 'input' files ref_loc = [] # root path for 'truth' files: ['test1','truth'] or ['test3'] ignore_table_keywords = [] ignore_fields = [] ignore_hdus = ['ASDF'] ignore_keywords = ['DATE', 'CAL_VER', 'CAL_VCS', 'CRDS_VER', 'CRDS_CTX', 'FILENAME'] @pytest.fixture(autouse=True) def config_env(self, pytestconfig, envopt): self.env = pytestconfig.getoption('env') @pytest.fixture(autouse=True) def config_access(self, pytestconfig): self.inputs_root = pytestconfig.getini('inputs_root')[0] self.results_root = pytestconfig.getini('results_root')[0] @property def repo_path(self): return [self.inputs_root, self.env, self.input_loc] def get_data(self, *pathargs, docopy=True): """ Download `filename` into working directory using `artifactory_helpers/get_bigdata()`. This will then return the full path to the local copy of the file. """ local_file = get_bigdata(*self.repo_path, *pathargs, docopy=docopy) return local_file def compare_outputs(self, outputs, raise_error=True, **kwargs): # Parse any user-specified kwargs ignore_keywords = kwargs.get('ignore_keywords', self.ignore_keywords) ignore_hdus = kwargs.get('ignore_hdus', self.ignore_hdus) ignore_fields = kwargs.get('ignore_fields', self.ignore_fields) rtol = kwargs.get('rtol', self.rtol) atol = kwargs.get('atol', self.atol) compare_kws = dict(ignore_fields=ignore_fields, ignore_hdus=ignore_hdus, ignore_keywords=ignore_keywords, rtol=rtol, atol=atol) input_path = [self.inputs_root, self.env, self.input_loc, *self.ref_loc] return compare_outputs(outputs, input_path=input_path, docopy=True, results_root=self.results_root, **compare_kws) def data_glob(self, *pathargs, glob='*'): """Retrieve file list matching glob Parameters ---------- pathargs: (str[, ...]) Path components glob: str The file name match criterion Returns ------- file_paths: [str[, ...]] File paths that match the glob criterion. Note that the TEST_BIGDATA and `repo_path` roots are removed so these results can be fed back into `get_data()` """ # Get full path and proceed depending on whether # is a local path or URL. root = get_bigdata_root() if op.exists(root): path = op.join(root, *self.repo_path) root_len = len(path) + 1 path = op.join(path, *pathargs) file_paths = _data_glob_local(path, glob) elif check_url(root): root_len = len(op.join(*self.repo_path[1:])) + 1 path = op.join(*self.repo_path, *pathargs) file_paths = _data_glob_url(path, glob, root=root) else: raise BigdataError('Path cannot be found: {}'.format(path)) # Remove the root from the paths file_paths = [ file_path[root_len:] for file_path in file_paths ] return file_paths # Pytest function to support the parameterization of BaseJWSTTestSteps def pytest_generate_tests(metafunc): # called once per each test function funcarglist = metafunc.cls.params[metafunc.function.__name__] argnames = sorted(funcarglist[0]) idlist = [funcargs['id'] for funcargs in funcarglist] del argnames[argnames.index('id')] metafunc.parametrize(argnames, [[funcargs[name] for name in argnames] for funcargs in funcarglist], ids=idlist) class BaseJWSTTestSteps(BaseJWSTTest): params = {'test_steps':[dict(input="", test_dir=None, step_class=None, step_pars=dict(), output_truth="", output_hdus=[]) ] } def test_steps(self, input, test_dir, step_class, step_pars, output_truth, output_hdus): """ Template method for parameterizing all the tests of JWST pipeline processing steps. """ if test_dir is None: return self.test_dir = test_dir self.ref_loc = [self.test_dir, 'truth'] # can be removed once all truth files have been updated self.ignore_keywords += ['FILENAME'] input_file = self.get_data(self.test_dir, input) result = step_class.call(input_file, save_results=True, **step_pars) output_file = result.meta.filename result.close() output_pars = None if isinstance(output_truth, tuple): output_pars = output_truth[1] output_truth = output_truth[0] if not output_pars: if output_hdus: output_spec = (output_file, output_truth, output_hdus) else: output_spec = (output_file, output_truth) else: output_spec = {'files':(output_file, output_truth), 'pars':output_pars} outputs = [output_spec] self.compare_outputs(outputs) def raw_from_asn(asn_file): """ Return a list of all input files from a given association. Parameters ---------- asn_file : str Filename for the ASN file. Returns ------- members : list of str A list of all input files in the association """ members = [] with open(asn_file) as f: asn = load_asn(f) for product in asn['products']: for member in product['members']: members.append(member['expname']) return members def _data_glob_local(*glob_parts): """Perform a glob on the local path Parameters ---------- glob_parts: (path-like,[...]) List of components that will be built into a single path Returns ------- file_paths: [str[, ...]] Full file paths that match the glob criterion """ full_glob = Path().joinpath(*glob_parts) return _sys_glob(str(full_glob)) def _data_glob_url(*url_parts, root=None): """ Parameters ---------- url: (str[,...]) List of components that will be used to create a URL path root: str The root server path to the Artifactory server. Normally retrieved from `get_bigdata_root`. Returns ------- url_paths: [str[, ...]] Full URLS that match the glob criterion """ # Fix root root-ed-ness if root.endswith('/'): root = root[:-1] # Access try: envkey = os.environ['API_KEY_FILE'] except KeyError: envkey = ARTIFACTORY_API_KEY_FILE try: with open(envkey) as fp: headers = {'X-JFrog-Art-Api': fp.readline().strip()} except (PermissionError, FileNotFoundError): print("Warning: Anonymous Artifactory search requests are limited to " "1000 results. Use an API key and define API_KEY_FILE environment " "variable to get full search results.", file=sys.stderr) headers = None search_url = '/'.join([root, 'api/search/pattern']) # Join and re-split the url so that every component is identified. url = '/'.join([root] + [idx for idx in url_parts]) all_parts = url.split('/') # Pick out "jwst-pipeline", the repo name repo = all_parts[4] # Format the pattern pattern = repo + ':' + '/'.join(all_parts[5:]) # Make the query params = {'pattern': pattern} with requests.get(search_url, params=params, headers=headers) as r: url_paths = r.json()['files'] return url_paths
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,516
mperrin/jwst
refs/heads/master
/jwst/master_background/tests/test_nirspec_corrections.py
""" Unit tests for master background NIRSpec corrections """ import numpy as np from jwst import datamodels from ..nirspec_corrections import correct_nrs_ifu_bkg def test_ifu_pathloss_existence(): """Test the case where the input is missing a pathloss array""" input = datamodels.IFUImageModel((10, 10)) result = correct_nrs_ifu_bkg(input) assert (result == input) def test_ifu_correction(): """Test application of IFU corrections""" data = np.ones((5, 5)) pl_ps = 2 * data pl_un = data / 2 input = datamodels.IFUImageModel(data=data, pathloss_point=pl_ps, pathloss_uniform=pl_un) corrected = input.data * pl_ps / pl_un result = correct_nrs_ifu_bkg(input) assert np.allclose(corrected, result.data, rtol=1.e-10)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,517
mperrin/jwst
refs/heads/master
/jwst/datamodels/tests/test_fits.py
import os import shutil import tempfile import pytest import numpy as np from numpy.testing import assert_array_equal from asdf import schema as mschema from .. import DataModel, ImageModel, RampModel from ..util import open ROOT_DIR = None FITS_FILE = None TMP_FITS = None TMP_FITS2 = None TMP_YAML = None TMP_JSON = None TMP_DIR = None def setup(): global ROOT_DIR, FITS_FILE, TMP_DIR, TMP_FITS, TMP_YAML, TMP_JSON, TMP_FITS2 ROOT_DIR = os.path.join(os.path.dirname(__file__), 'data') FITS_FILE = os.path.join(ROOT_DIR, 'test.fits') TMP_DIR = tempfile.mkdtemp() TMP_FITS = os.path.join(TMP_DIR, 'tmp.fits') TMP_YAML = os.path.join(TMP_DIR, 'tmp.yaml') TMP_JSON = os.path.join(TMP_DIR, 'tmp.json') TMP_FITS2 = os.path.join(TMP_DIR, 'tmp2.fits') def teardown(): shutil.rmtree(TMP_DIR) def records_equal(a, b): a = a.item() b = b.item() a_size = len(a) b_size = len(b) equal = a_size == b_size for i in range(a_size): if not equal: break equal = a[i] == b[i] return equal def test_from_new_hdulist(): with pytest.raises(AttributeError): from astropy.io import fits hdulist = fits.HDUList() with open(hdulist) as dm: dm.data def test_from_new_hdulist2(): from astropy.io import fits hdulist = fits.HDUList() data = np.empty((50, 50), dtype=np.float32) primary = fits.PrimaryHDU() hdulist.append(primary) science = fits.ImageHDU(data=data, name='SCI') hdulist.append(science) with open(hdulist) as dm: dq = dm.dq assert dq is not None def test_setting_arrays_on_fits(): from astropy.io import fits hdulist = fits.HDUList() data = np.empty((50, 50), dtype=np.float32) primary = fits.PrimaryHDU() hdulist.append(primary) science = fits.ImageHDU(data=data, name='SCI') hdulist.append(science) with open(hdulist) as dm: dm.data = np.empty((50, 50), dtype=np.float32) dm.dq = np.empty((10, 50, 50), dtype=np.uint32) def delete_array(): with pytest.raises(AttributeError): from astropy.io import fits hdulist = fits.HDUList() data = np.empty((50, 50)) science = fits.ImageHDU(data=data, name='SCI') hdulist.append(science) hdulist.append(science) with open(hdulist) as dm: del dm.data assert len(hdulist) == 1 def test_from_fits(): with RampModel(FITS_FILE) as dm: assert dm.meta.instrument.name == 'MIRI' assert dm.shape == (5, 35, 40, 32) def test_from_scratch(): with ImageModel((50, 50)) as dm: data = np.asarray(np.random.rand(50, 50), np.float32) dm.data[...] = data dm.meta.instrument.name = 'NIRCAM' dm.to_fits(TMP_FITS, overwrite=True) with ImageModel.from_fits(TMP_FITS) as dm2: assert dm2.shape == (50, 50) assert dm2.meta.instrument.name == 'NIRCAM' assert dm2.dq.dtype.name == 'uint32' assert np.all(dm2.data == data) def test_delete(): with DataModel(FITS_FILE) as dm: dm.meta.instrument.name = 'NIRCAM' assert dm.meta.instrument.name == 'NIRCAM' del dm.meta.instrument.name assert dm.meta.instrument.name is None # def test_section(): # with RampModel((5, 35, 40, 32)) as dm: # section = dm.get_section('data')[3:4, 1:3] # assert section.shape == (1, 2, 40, 32) # def test_date_obs(): # with DataModel(FITS_FILE) as dm: # assert dm.meta.observation.date.microsecond == 314592 def test_fits_without_sci(): from astropy.io import fits schema = { "allOf": [ mschema.load_schema( os.path.join(os.path.dirname(__file__), "../schemas/core.schema.yaml"), resolve_references=True), { "type": "object", "properties": { "coeffs": { 'max_ndim': 1, 'fits_hdu': 'COEFFS', 'datatype': 'float32' } } } ] } fits = fits.HDUList( [fits.PrimaryHDU(), fits.ImageHDU(name='COEFFS', data=np.array([0.0], np.float32))]) with DataModel(fits, schema=schema) as dm: assert_array_equal(dm.coeffs, [0.0]) def _header_to_dict(x): return dict((a, b) for (a, b, c) in x) def test_extra_fits(): path = os.path.join(ROOT_DIR, "headers.fits") assert os.path.exists(path) with DataModel(path) as dm: assert 'BITPIX' not in _header_to_dict(dm.extra_fits.PRIMARY.header) assert _header_to_dict(dm.extra_fits.PRIMARY.header)['SCIYSTRT'] == 705 dm2 = dm.copy() dm2.to_fits(TMP_FITS, overwrite=True) with DataModel(TMP_FITS) as dm: assert 'BITPIX' not in _header_to_dict(dm.extra_fits.PRIMARY.header) assert _header_to_dict(dm.extra_fits.PRIMARY.header)['SCIYSTRT'] == 705 def test_hdu_order(): from astropy.io import fits with ImageModel(data=np.array([[0.0]]), dq=np.array([[0.0]]), err=np.array([[0.0]])) as dm: dm.save(TMP_FITS) with fits.open(TMP_FITS, memmap=False) as hdulist: assert hdulist[1].header['EXTNAME'] == 'SCI' assert hdulist[2].header['EXTNAME'] == 'DQ' assert hdulist[3].header['EXTNAME'] == 'ERR' def test_casting(): with RampModel(FITS_FILE) as dm: sum = np.sum(dm.data) dm.data[:] = dm.data + 2 assert np.sum(dm.data) > sum # def test_comments(): # with RampModel(FITS_FILE) as dm: # assert 'COMMENT' in (x[0] for x in dm._extra_fits.PRIMARY) # dm._extra_fits.PRIMARY.COMMENT = ['foobar'] # assert dm._extra_fits.PRIMARY.COMMENT == ['foobar'] def test_fits_comments(): with ImageModel() as dm: dm.meta.subarray.xstart = 42 dm.save(TMP_FITS, overwrite=True) from astropy.io import fits with fits.open(TMP_FITS, memmap=False) as hdulist: header = hdulist[0].header find = ['Subarray parameters'] found = 0 for card in header.cards: if card[1] in find: found += 1 assert found == len(find) def test_metadata_doesnt_override(): with ImageModel() as dm: dm.save(TMP_FITS, overwrite=True) from astropy.io import fits with fits.open(TMP_FITS, mode='update', memmap=False) as hdulist: hdulist[0].header['FILTER'] = 'F150W2' with ImageModel(TMP_FITS) as dm: assert dm.meta.instrument.filter == 'F150W2' def test_table_with_metadata(): schema = { "allOf": [ mschema.load_schema( os.path.join(os.path.dirname(__file__), "../schemas/core.schema.yaml"), resolve_references=True), {"type": "object", "properties": { "flux_table": { "title": "Photometric flux conversion table", "fits_hdu": "FLUX", "datatype": [ {"name": "parameter", "datatype": ['ascii', 7]}, {"name": "factor", "datatype": "float64"}, {"name": "uncertainty", "datatype": "float64"} ] }, "meta": { "type": "object", "properties": { "fluxinfo": { "title": "Information about the flux conversion", "type": "object", "properties": { "exposure": { "title": "Description of exposure analyzed", "type": "string", "fits_hdu": "FLUX", "fits_keyword": "FLUXEXP" } } } } } } } ] } class FluxModel(DataModel): def __init__(self, init=None, flux_table=None, **kwargs): super(FluxModel, self).__init__(init=init, schema=schema, **kwargs) if flux_table is not None: self.flux_table = flux_table flux_im = [ ('F560W', 1.0e-5, 1.0e-7), ('F770W', 1.1e-5, 1.6e-7), ] with FluxModel(flux_table=flux_im) as datamodel: datamodel.meta.fluxinfo.exposure = 'Exposure info' datamodel.save(TMP_FITS, overwrite=True) del datamodel from astropy.io import fits with fits.open(TMP_FITS, memmap=False) as hdulist: assert len(hdulist) == 3 assert isinstance(hdulist[1], fits.BinTableHDU) assert hdulist[1].name == 'FLUX' assert hdulist[2].name == 'ASDF' def test_replace_table(): from astropy.io import fits schema_narrow = { "allOf": [ mschema.load_schema( os.path.join(os.path.dirname(__file__), "../schemas/core.schema.yaml"), resolve_references=True), { "type": "object", "properties": { "data": { "title": "relative sensitivity table", "fits_hdu": "RELSENS", "datatype": [ {"name": "TYPE", "datatype": ["ascii", 16]}, {"name": "T_OFFSET", "datatype": "float32"}, {"name": "DECAY_PEAK", "datatype": "float32"}, {"name": "DECAY_FREQ", "datatype": "float32"}, {"name": "TAU", "datatype": "float32"} ] } } } ] } schema_wide = { "allOf": [ mschema.load_schema( os.path.join(os.path.dirname(__file__), "../schemas/core.schema.yaml"), resolve_references=True), { "type": "object", "properties": { "data": { "title": "relative sensitivity table", "fits_hdu": "RELSENS", "datatype": [ {"name": "TYPE", "datatype": ["ascii", 16]}, {"name": "T_OFFSET", "datatype": "float64"}, {"name": "DECAY_PEAK", "datatype": "float64"}, {"name": "DECAY_FREQ", "datatype": "float64"}, {"name": "TAU", "datatype": "float64"} ] } } } ] } x = np.array([("string", 1., 2., 3., 4.)], dtype=[('TYPE', 'S16'), ('T_OFFSET', np.float32), ('DECAY_PEAK', np.float32), ('DECAY_FREQ', np.float32), ('TAU', np.float32)]) m = DataModel(schema=schema_narrow) m.data = x m.to_fits(TMP_FITS, overwrite=True) with fits.open(TMP_FITS, memmap=False) as hdulist: assert records_equal(x, np.asarray(hdulist[1].data)) assert hdulist[1].data.dtype[1].str == '>f4' assert hdulist[1].header['TFORM2'] == 'E' with DataModel(TMP_FITS, schema=schema_wide) as m: m.to_fits(TMP_FITS2, overwrite=True) with fits.open(TMP_FITS2, memmap=False) as hdulist: assert records_equal(x, np.asarray(hdulist[1].data)) assert hdulist[1].data.dtype[1].str == '>f8' assert hdulist[1].header['TFORM2'] == 'D' def test_table_with_unsigned_int(): schema = { 'title': 'Test data model', '$schema': 'http://stsci.edu/schemas/fits-schema/fits-schema', 'type': 'object', 'properties': { 'meta': { 'type': 'object', 'properties': {} }, 'test_table': { 'title': 'Test table', 'fits_hdu': 'TESTTABL', 'datatype': [ {'name': 'FLOAT64_COL', 'datatype': 'float64'}, {'name': 'UINT32_COL', 'datatype': 'uint32'} ] } } } with DataModel(schema=schema) as dm: float64_info = np.finfo(np.float64) float64_arr = np.random.uniform(size=(10,)) float64_arr[0] = float64_info.min float64_arr[-1] = float64_info.max uint32_info = np.iinfo(np.uint32) uint32_arr = np.random.randint(uint32_info.min, uint32_info.max + 1, size=(10,), dtype=np.uint32) uint32_arr[0] = uint32_info.min uint32_arr[-1] = uint32_info.max test_table = np.array(list(zip(float64_arr, uint32_arr)), dtype=dm.test_table.dtype) def assert_table_correct(model): for idx, (col_name, col_data) in enumerate([('float64_col', float64_arr), ('uint32_col', uint32_arr)]): # The table dtype and field dtype are stored separately, and may not # necessarily agree. assert np.can_cast(model.test_table.dtype[idx], col_data.dtype, 'equiv') assert np.can_cast(model.test_table.field(col_name).dtype, col_data.dtype, 'equiv') assert np.array_equal(model.test_table.field(col_name), col_data) # The datamodel casts our array to FITS_rec on assignment, so here we're # checking that the data survived the casting. dm.test_table = test_table assert_table_correct(dm) # Confirm that saving the table (and converting the uint32 values to signed int w/TZEROn) # doesn't mangle the data. dm.save(TMP_FITS) assert_table_correct(dm) # Confirm that the data loads from the file intact (converting the signed ints back to # the appropriate uint32 values). with DataModel(TMP_FITS, schema=schema) as dm2: assert_table_correct(dm2) def test_metadata_from_fits(): from astropy.io import fits mask = np.array([[0, 1], [2, 3]]) fits.ImageHDU(data=mask, name='DQ').writeto(TMP_FITS, overwrite=True) with DataModel(init=TMP_FITS) as dm: dm.save(TMP_FITS2) with fits.open(TMP_FITS2, memmap=False) as hdulist: assert hdulist[2].name == 'ASDF' # def test_float_as_int(): # from astropy.io import fits # hdulist = fits.HDUList() # primary = fits.PrimaryHDU() # hdulist.append(primary) # hdulist[0].header['SUBSTRT1'] = 42.7 # hdulist.writeto(TMP_FITS, overwrite=True) # with DataModel(TMP_FITS) as dm: # assert dm.meta.subarray.xstart == 42.7
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,518
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py
import pytest from jwst.pipeline.calwebb_image2 import Image2Pipeline from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestImage2Pipeline(BaseJWSTTest): input_loc = 'fgs' ref_loc = ['test_image2pipeline', 'truth'] def test_fgs_image2pipeline1(self): """ Regression test of calwebb_image2 pipeline performed on FGS imaging mode data. """ input_file = self.get_data('test_image2pipeline', 'jw86500007001_02101_00001_GUIDER2_rate.fits') output_file = 'jw86500007001_02101_00001_GUIDER2_cal.fits' Image2Pipeline.call(input_file, save_results=True) outputs = [(output_file, 'jw86500007001_02101_00001_GUIDER2_cal_ref.fits')] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,519
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py
import pytest from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestSpec2Pipeline(BaseJWSTTest): input_loc = 'miri' ref_loc = ['test_spec2pipeline', 'truth'] def test_mirilrs2pipeline1(self): """ Regression test of calwebb_spec2 pipeline performed on MIRI LRS slitless data. """ input_file = self.get_data('test_spec2pipeline', 'jw80600012001_02101_00003_mirimage_rateints.fits') collect_pipeline_cfgs() args = [ 'calwebb_tso-spec2.cfg', input_file, ] Step.from_cmdline(args) outputs = [('jw80600012001_02101_00003_mirimage_calints.fits', 'jw80600012001_02101_00003_mirimage_calints_ref.fits', ['primary', 'sci', 'err', 'dq'] ), ('jw80600012001_02101_00003_mirimage_x1dints.fits', 'jw80600012001_02101_00003_mirimage_x1dints_ref.fits', ['primary', ('extract1d', 1), ('extract1d', 2), ('extract1d', 3), ('extract1d', 4)] ) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,520
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py
import pytest import numpy as np from numpy.testing import assert_allclose from gwcs.wcstools import grid_from_bounding_box from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn from jwst.assign_wcs import AssignWcsStep, nirspec from jwst.datamodels import ImageModel from jwst.pipeline import Detector1Pipeline, Spec2Pipeline from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.imprint import ImprintStep from jwst.ramp_fitting import RampFitStep from jwst.master_background import MasterBackgroundStep from jwst import datamodels @pytest.mark.bigdata class TestDetector1Pipeline(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_pipelines', 'truth'] test_dir = 'test_pipelines' def test_detector1pipeline4(self): """ Regression test of calwebb_detector1 pipeline performed on NIRSpec data. """ input_file = self.get_data(self.test_dir, 'jw84600007001_02101_00001_nrs1_uncal.fits') step = Detector1Pipeline() step.save_calibrated_ramp = True step.ipc.skip = True step.persistence.skip = True step.jump.rejection_threshold = 4.0 step.ramp_fit.save_opt = False step.output_file = 'jw84600007001_02101_00001_nrs1_rate.fits' step.run(input_file) outputs = [('jw84600007001_02101_00001_nrs1_ramp.fits', 'jw84600007001_02101_00001_nrs1_ramp_ref.fits'), ('jw84600007001_02101_00001_nrs1_rate.fits', 'jw84600007001_02101_00001_nrs1_rate_ref.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRSpecImprint(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_imprint', 'truth'] test_dir = 'test_imprint' def test_imprint_nirspec(self): """ Regression test of imprint step performed on NIRSpec MSA data. """ input_file = self.get_data(self.test_dir, 'jw00038001001_01101_00001_NRS1_rate.fits') model_file = self.get_data(self.test_dir, 'NRSMOS-MODEL-21_NRS1_rate.fits') result = ImprintStep.call(input_file, model_file, name='imprint') output_file = result.meta.filename result.save(output_file) result.close() outputs = [(output_file, 'jw00038001001_01101_00001_NRS1_imprint.fits')] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRSpecRampFit(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_ramp_fit', 'truth'] test_dir = 'test_ramp_fit' def test_ramp_fit_nirspec(self): """ Regression test of ramp_fit step performed on NIRSpec data. This is a single integration dataset. """ input_file = self.get_data(self.test_dir, 'jw00023001001_01101_00001_NRS1_jump.fits') result, result_int = RampFitStep.call(input_file, save_opt=True, opt_name='rampfit_opt_out.fits', name='RampFit' ) output_file = result.meta.filename result.save(output_file) result.close() outputs = [(output_file, 'jw00023001001_01101_00001_NRS1_ramp_fit.fits'), ('rampfit_opt_out_fitopt.fits', 'jw00023001001_01101_00001_NRS1_opt.fits', ['primary','slope','sigslope','yint','sigyint', 'pedestal','weights','crmag']) ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRSpecWCS(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_wcs', 'nrs1-fs', 'truth'] test_dir = ['test_wcs', 'nrs1-fs'] def test_nirspec_nrs1_wcs(self): """ Regression test of creating a WCS object and doing pixel to sky transformation. """ input_file = self.get_data(*self.test_dir, 'jw00023001001_01101_00001_NRS1_ramp_fit.fits') ref_file = self.get_data(*self.ref_loc, 'jw00023001001_01101_00001_NRS1_ramp_fit_assign_wcs.fits') result = AssignWcsStep.call(input_file, save_results=True, suffix='assign_wcs') result.close() im = ImageModel(result.meta.filename) imref = ImageModel(ref_file) for slit in ['S200A1', 'S200A2', 'S400A1', 'S1600A1']: w = nirspec.nrs_wcs_set_input(im, slit) grid = grid_from_bounding_box(w.bounding_box) ra, dec, lam = w(*grid) wref = nirspec.nrs_wcs_set_input(imref, slit) raref, decref, lamref = wref(*grid) assert_allclose(ra, raref, equal_nan=True) assert_allclose(dec, decref, equal_nan=True) assert_allclose(lam, lamref, equal_nan=True) @pytest.mark.bigdata class TestNRSSpec2(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_pipelines', 'truth'] test_dir = 'test_pipelines' def test_nrs_fs_single_spec2(self): """ Regression test of calwebb_spec2 pipeline performed on NIRSpec fixed-slit data that uses a single-slit subarray (S200B1). """ input_file = self.get_data(self.test_dir, 'jw84600002001_02101_00001_nrs2_rate.fits') step = Spec2Pipeline() step.save_bsub = True step.save_results = True step.resample_spec.save_results = True step.cube_build.save_results = True step.extract_1d.save_results = True step.run(input_file) outputs = [('jw84600002001_02101_00001_nrs2_cal.fits', 'jw84600002001_02101_00001_nrs2_cal_ref.fits'), ('jw84600002001_02101_00001_nrs2_s2d.fits', 'jw84600002001_02101_00001_nrs2_s2d_ref.fits'), ('jw84600002001_02101_00001_nrs2_x1d.fits', 'jw84600002001_02101_00001_nrs2_x1d_ref.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRSpecMasterBackground_FS(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_masterbackground', 'nrs-fs', 'truth'] test_dir = ['test_masterbackground', 'nrs-fs'] def test_nirspec_fs_masterbg_user(self): """ Regression test of master background subtraction for NRS FS when a user 1-D spectrum is provided. """ # input file has 2-D background image added to it input_file = self.get_data(*self.test_dir, 'nrs_sci+bkg_cal.fits') # user provided 1-D background was created from the 2-D background image input_1dbkg_file = self.get_data(*self.test_dir, 'nrs_bkg_user_clean_x1d.fits') result = MasterBackgroundStep.call(input_file, user_background=input_1dbkg_file, save_results=True) # Compare background-subtracted science data (results) # to a truth file. These data are MultiSlitModel data result_file = result.meta.filename truth_file = self.get_data(*self.ref_loc, 'nrs_sci+bkg_masterbackgroundstep.fits') outputs = [(result_file, truth_file)] self.compare_outputs(outputs) result.close() @pytest.mark.bigdata class TestNIRSpecMasterBackground_IFU(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_masterbackground', 'nrs-ifu', 'truth'] test_dir = ['test_masterbackground', 'nrs-ifu'] def test_nirspec_ifu_masterbg_user(self): """ Regression test of master background subtraction for NRS IFU when a user 1-D spectrum is provided. """ # input file has 2-D background image added to it input_file = self.get_data(*self.test_dir, 'prism_sci_bkg_cal.fits') # user-provided 1-D background was created from the 2-D background image user_background = self.get_data(*self.test_dir, 'prism_bkg_x1d.fits') result = MasterBackgroundStep.call(input_file, user_background=user_background, save_results=True) # Test 2 compare the science data with no background # to the output from the masterBackground Subtraction step # background subtracted science image. input_sci_cal_file = self.get_data(*self.test_dir, 'prism_sci_cal.fits') input_sci_model = datamodels.open(input_sci_cal_file) # We don't want the slices gaps to impact the statisitic # loop over the 30 Slices for i in range(30): slice_wcs = nirspec.nrs_wcs_set_input(input_sci_model, i) x, y = grid_from_bounding_box(slice_wcs.bounding_box) ra, dec, lam = slice_wcs(x, y) valid = np.isfinite(lam) result_slice_region = result.data[y.astype(int), x.astype(int)] sci_slice_region = input_sci_model.data[y.astype(int), x.astype(int)] sci_slice = sci_slice_region[valid] result_slice = result_slice_region[valid] sub = result_slice - sci_slice # check for outliers in the science image sci_mean = np.nanmean(sci_slice) sci_std = np.nanstd(sci_slice) upper = sci_mean + sci_std*5.0 lower = sci_mean - sci_std*5.0 mask_clean = np.logical_and(sci_slice < upper, sci_slice > lower) sub_mean = np.absolute(np.nanmean(sub[mask_clean])) atol = 2.0 assert_allclose(sub_mean, 0, atol=atol) # Test 3 Compare background sutracted science data (results) # to a truth file. This data is MultiSlit data input_sci_model.close() result_file = result.meta.filename truth_file = self.get_data(*self.ref_loc, 'prism_sci_bkg_masterbackgroundstep.fits') outputs = [(result_file, truth_file)] self.compare_outputs(outputs) input_sci_model.close() result.close() @pytest.mark.bigdata class TestNIRSpecMasterBackground_MOS(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_masterbackground', 'nrs-mos', 'truth'] test_dir = ['test_masterbackground', 'nrs-mos'] def test_nirspec_mos_masterbg_user(self): """ Regression test of master background subtraction for NRS MOS when a user 1-D spectrum is provided. """ # input file has 2-D background image added to it input_file = self.get_data(*self.test_dir, 'nrs_mos_sci+bkg_cal.fits') # user provide 1-D background was created from the 2-D background image input_1dbkg_file = self.get_data(*self.test_dir, 'nrs_mos_bkg_x1d.fits') result = MasterBackgroundStep.call(input_file, user_background=input_1dbkg_file, save_results=True) # Compare background subtracted science data (results) # to a truth file. These data are MultiSlit data. result_file = result.meta.filename ref_file = self.get_data(*self.ref_loc, 'nrs_mos_sci+bkg_masterbackgroundstep.fits') outputs = [(result_file, ref_file)] self.compare_outputs(outputs) result.close() @pytest.mark.bigdata class TestNIRSpecMasterBackgroundNodded(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_masterbackground', 'nrs-ifu', 'nodded', 'truth'] test_dir = ['test_masterbackground', 'nrs-ifu', 'nodded'] rtol = 0.000001 def test_nirspec_masterbg_nodded(self): """Run masterbackground step on NIRSpec association""" asn_file = self.get_data(*self.test_dir, 'nirspec_spec3_asn.json') for file in raw_from_asn(asn_file): self.get_data(*self.test_dir, file) collect_pipeline_cfgs('./config') result = MasterBackgroundStep.call( asn_file, config_file='config/master_background.cfg', save_background=True, save_results=True ) # test 1 # compare background subtracted data to truth files # check that the cal_step master_background ran to complete outputs = [] for model in result: assert model.meta.cal_step.master_background == 'COMPLETE' result_file = model.meta.filename.replace('cal', 'master_background') truth_file = self.get_data(*self.ref_loc, result_file) outputs.append((result_file, truth_file)) self.compare_outputs(outputs) # test 2 # compare the master background combined file to truth file master_combined_bkg_file = 'ifu_prism_source_off_fix_NRS1_o001_masterbg.fits' truth_background = self.get_data(*self.ref_loc, master_combined_bkg_file) outputs = [(master_combined_bkg_file, truth_background)] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,521
mperrin/jwst
refs/heads/master
/jwst/stpipe/tests/test_pipeline.py
from os.path import dirname, join, abspath import sys import numpy as np from numpy.testing import assert_allclose import pytest from jwst.stpipe import Step, Pipeline, LinearPipeline from jwst import datamodels # TODO: Test system call steps def library_function(): import logging log = logging.getLogger() log.info("This is a library function log") class FlatField(Step): """ An example flat-fielding Step. """ # Load the spec from a file def process(self, science, flat): self.log.info("Removing flat field") self.log.info("Threshold: {0}".format(self.threshold)) library_function() output = datamodels.ImageModel(data=science.data - flat.data) return output class Combine(Step): """ A Step that combines a list of images. """ def process(self, images): combined = np.zeros((50, 50)) for image in images: combined += image.data return datamodels.ImageModel(data=combined) class Display(Step): """ A Step to display an image. """ def process(self, image): pass class MultiplyBy2(Step): """ A Step that does the incredibly complex thing of multiplying by 2. """ def process(self, image): with datamodels.ImageModel(image) as dm: dm2 = datamodels.ImageModel() dm2.data = dm.data * 2 return dm2 class MyPipeline(Pipeline): """ A test pipeline. """ step_defs = { 'flat_field': FlatField, 'combine': Combine, 'display': Display } spec = """ science_filename = input_file() # The input science filename flat_filename = input_file(default=None) # The input flat filename output_filename = output_file() # The output filename """ def process(self, *args): science = datamodels.open(self.science_filename) if self.flat_filename is None: self.flat_filename = join(dirname(__file__), "data/flat.fits") flat = datamodels.open(self.flat_filename) calibrated = [] calibrated.append(self.flat_field(science, flat)) combined = self.combine(calibrated) self.display(combined) dm = datamodels.ImageModel(combined) dm.save(self.output_filename) science.close() flat.close() return dm def test_pipeline(_jail): pipeline_fn = join(dirname(__file__), 'steps', 'python_pipeline.cfg') pipe = Step.from_config_file(pipeline_fn) pipe.output_filename = "output.fits" assert pipe.flat_field.threshold == 42.0 assert pipe.flat_field.multiplier == 2.0 pipe.run() def test_pipeline_python(_jail): steps = { 'flat_field': {'threshold': 42.0} } pipe = MyPipeline( "MyPipeline", config_file=__file__, steps=steps, science_filename=abspath(join(dirname(__file__), 'data', 'science.fits')), flat_filename=abspath(join(dirname(__file__), 'data', 'flat.fits')), output_filename="output.fits") assert pipe.flat_field.threshold == 42.0 assert pipe.flat_field.multiplier == 1.0 pipe.run() class MyLinearPipeline(LinearPipeline): pipeline_steps = [ ('multiply', MultiplyBy2), ('multiply2', MultiplyBy2), ('multiply3', MultiplyBy2) ] def test_partial_pipeline(_jail): pipe = MyLinearPipeline() pipe.end_step = 'multiply2' result = pipe.run(abspath(join(dirname(__file__), 'data', 'science.fits'))) pipe.start_step = 'multiply3' pipe.end_step = None result = pipe.run(abspath(join(dirname(__file__), 'data', 'science.fits'))) assert_allclose(np.sum(result.data), 9969.82514685, rtol=1e-4) def test_pipeline_commandline(_jail): args = [ abspath(join(dirname(__file__), 'steps', 'python_pipeline.cfg')), '--steps.flat_field.threshold=47' ] pipe = Step.from_cmdline(args) assert pipe.flat_field.threshold == 47.0 assert pipe.flat_field.multiplier == 2.0 pipe.run() def test_pipeline_commandline_class(_jail): args = [ 'jwst.stpipe.tests.test_pipeline.MyPipeline', '--logcfg={0}'.format( abspath(join(dirname(__file__), 'steps', 'log.cfg'))), # The file_name parameters are *required* '--science_filename={0}'.format( abspath(join(dirname(__file__), 'data', 'science.fits'))), '--output_filename={0}'.format( 'output.fits'), '--steps.flat_field.threshold=47' ] pipe = Step.from_cmdline(args) assert pipe.flat_field.threshold == 47.0 assert pipe.flat_field.multiplier == 1.0 pipe.run() def test_pipeline_commandline_invalid_args(): from io import StringIO args = [ 'jwst.stpipe.tests.test_pipeline.MyPipeline', # The file_name parameters are *required*, and one of them # is missing, so we should get a message to that effect # followed by the commandline usage message. '--flat_filename={0}'.format( abspath(join(dirname(__file__), 'data', 'flat.fits'))), '--steps.flat_field.threshold=47' ] sys.stdout = buffer = StringIO() with pytest.raises(ValueError): Step.from_cmdline(args) help = buffer.getvalue() assert "Multiply by this number" in help
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,522
mperrin/jwst
refs/heads/master
/jwst/rscd/__init__.py
from .rscd_step import RSCD_Step __all__ = ['RSCD_Step']
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,523
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py
import pytest from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn from jwst.pipeline import ( Ami3Pipeline, Detector1Pipeline, ) from jwst.ramp_fitting import RampFitStep from jwst.photom import PhotomStep from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step @pytest.mark.bigdata class TestAMIPipeline(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_ami_pipeline', 'truth'] test_dir = 'test_ami_pipeline' def test_ami_pipeline(self): """ Regression test of the AMI pipeline performed on NIRISS AMI data. """ asn_file = self.get_data(self.test_dir, 'test_lg1_asn.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) pipe = Ami3Pipeline() pipe.save_averages = True pipe.ami_analyze.oversample = 3 pipe.ami_analyze.rotation = 1.49 pipe.run(asn_file) outputs = [('test_targ_aminorm.fits', 'ami_pipeline_targ_lgnorm.fits'), ] self.compare_outputs(outputs, rtol=0.00001, ignore_hdus=['ASDF', 'HDRTAB']) @pytest.mark.bigdata class TestDetector1Pipeline(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_detector1pipeline', 'truth'] test_dir = 'test_detector1pipeline' def test_niriss_detector1(self): """ Regression test of calwebb_detector1 pipeline performed on NIRISS data. """ input_file = self.get_data(self.test_dir, 'jw00034001001_01101_00001_NIRISS_uncal.fits') step = Detector1Pipeline() step.save_calibrated_ramp = True step.ipc.skip = True step.persistence.skip = True step.refpix.odd_even_columns = True step.refpix.use_side_ref_pixels = True step.refpix.side_smoothing_length = 11 step.refpix.side_gain = 1.0 step.refpix.odd_even_rows = True step.jump.rejection_threshold = 250.0 step.ramp_fit.save_opt = False step.ramp_fit.suffix = 'ramp' step.output_file = 'jw00034001001_01101_00001_NIRISS_rate.fits' step.run(input_file) outputs = [('jw00034001001_01101_00001_NIRISS_ramp.fits', 'jw00034001001_01101_00001_NIRISS_ramp_ref.fits'), ('jw00034001001_01101_00001_NIRISS_rate.fits', 'jw00034001001_01101_00001_NIRISS_rate_ref.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRISSSOSS2Pipeline(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_spec2pipeline', 'truth'] test_dir = 'test_spec2pipeline' def test_nirisssoss2pipeline1(self): """ Regression test of calwebb_tso_spec2 pipeline performed on NIRISS SOSS data. """ input_file = self.get_data(self.test_dir, 'jw10003001002_03101_00001-seg003_nis_rateints.fits') collect_pipeline_cfgs() args = [ 'calwebb_tso-spec2.cfg', input_file ] Step.from_cmdline(args) outputs = [{'files':('jw10003001002_03101_00001-seg003_nis_calints.fits', 'jw10003001002_03101_00001-seg003_nis_calints_ref.fits'), 'pars':dict(ignore_hdus=['INT_TIMES', 'VAR_POISSON', 'VAR_RNOISE', 'ASDF'])}, {'files':('jw10003001002_03101_00001-seg003_nis_x1dints.fits', 'jw10003001002_03101_00001-seg003_nis_x1dints_ref.fits'), 'pars':dict(ignore_hdus=['INT_TIMES', 'ASDF'])} ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRISSPhotom(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_photom', 'truth'] test_dir = 'test_photom' def test_photom_niriss(self): """ Regression test of photom step performed on NIRISS imaging data. """ input_file = self.get_data(self.test_dir, 'jw00034001001_01101_00001_NIRISS_flat_field.fits') result = PhotomStep.call(input_file) output_file = result.meta.filename result.save(output_file) result.close() outputs = [(output_file, 'jw00034001001_01101_00001_NIRISS_photom.fits') ] self.compare_outputs(outputs) @pytest.mark.bigdata class TestNIRISSRampFit(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_ramp_fit', 'truth'] test_dir = 'test_ramp_fit' def test_ramp_fit_niriss(self): """ Regression test of ramp_fit step performed on NIRISS data. """ input_file = self.get_data(self.test_dir, 'jw00034001001_01101_00001_NIRISS_jump.fits') result, result_int = RampFitStep.call(input_file, save_opt=True, opt_name='rampfit_opt_out.fits' ) output_file = result.meta.filename result.save(output_file) result.close() outputs = [(output_file, 'jw00034001001_01101_00001_NIRISS_ramp_fit.fits'), ('rampfit_opt_out_fitopt.fits', 'jw00034001001_01101_00001_NIRISS_uncal_opt.fits', ['primary','slope','sigslope','yint','sigyint', 'pedestal','weights','crmag']) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,524
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py
"""Test calwebb_spec3 against NIRSpec Fixed-slit science (FSS)""" from glob import glob from os import path import pytest from jwst.associations import load_asn from jwst.pipeline import Spec3Pipeline from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestSpec3Pipeline(BaseJWSTTest): input_loc = 'nirspec' def test_save_source_only(self): """Test saving the source-based files only""" datapath = ['test_datasets', 'fss', '93045', 'level2b'] asn_file = self.get_data(*datapath, 'jw93045-o010_20180725t035735_spec3_001_asn.json') for file in raw_from_asn(asn_file): self.get_data(*datapath, file) pipe = Spec3Pipeline() pipe.mrs_imatch.skip = True pipe.outlier_detection.skip = True pipe.resample_spec.skip = True pipe.cube_build.skip = True pipe.extract_1d.skip = True pipe.run(asn_file) # Check resulting product with open(asn_file) as fh: asn = load_asn(fh) base_name = asn['products'][0]['name'] product_name = base_name.format(source_id='s00000') + '_cal.fits' output_files = glob('*') if product_name in output_files: output_files.remove(product_name) else: assert False @pytest.mark.xfail( reason='See Issue JP-1144', run=False ) def test_nrs_fs_spec3(self): """ Regression test of calwebb_spec3 pipeline performed on NIRSpec fixed-slit data. """ cfg_dir = './cfgs' collect_pipeline_cfgs(cfg_dir) datapath = ['test_datasets', 'fss', '93045', 'level2b'] asn_file = self.get_data(*datapath, 'jw93045-o010_20180725t035735_spec3_001_asn.json') for file in raw_from_asn(asn_file): self.get_data(*datapath, file) args = [ path.join(cfg_dir, 'calwebb_spec3.cfg'), asn_file ] Step.from_cmdline(args) # Compare results outputs = [('jw00023001001_01101_00001_NRS1_cal.fits', 'jw00023001001_01101_00001_NRS1_cal_ref.fits'), ('jw00023001001_01101_00001_NRS1_s2d.fits', 'jw00023001001_01101_00001_NRS1_s2d_ref.fits'), ('jw00023001001_01101_00001_NRS1_x1d.fits', 'jw00023001001_01101_00001_NRS1_x1d_ref.fits') ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,525
mperrin/jwst
refs/heads/master
/jwst/datamodels/ndmodel.py
""" Subclass of NDDataBase to support DataModel compatibility with NDData """ import os.path import numpy as np import collections from astropy.units import Quantity from astropy.nddata import nddata_base from . import util from . import filetype from . import properties #--------------------------------------- # astropy.io.registry compatibility #--------------------------------------- def identify(origin, path, fileobj, *args, **kwargs): """ Identify if file is a DataModel for astropy.io.registry """ if fileobj: file_type = filetype.check(fileobj) elif path: if os.path.isfile(path): file_type = filetype.check(path) else: file_type = path.lower().split(".")[1] else: file_type = None flag = file_type and (file_type == "asdf" or file_type == "fits") return flag def read(data, *args, **kwargs): """ Astropy.io registry compatibility function to wrap util.open """ # Translate keyword arguments to those expected by ImageModel xargs = {} if kwargs.get("mask"): xargs["dq"] = kwargs["mask"] uncertainty = kwargs.get("uncertainty") if uncertainty: if isinstance(uncertainty, Quantity): uncertainty_type = uncertainty.unit uncertainty = uncertainty.data else: uncertainty_type = None xargs["err"] = uncertainty else: uncertainty_type = None if hasattr(data, 'mask') and hasattr(data, 'data'): xargs["dq"] = data.mask data = data.data if isinstance(data, Quantity): unit = data.unit data = data.value else: unit = kwargs.get("unit") # Create the model using the transformed arguments model = util.open(data, **xargs) # Add attributes passed as keyword arguments to model if unit: model.meta.bunit_data = unit wcs = kwargs.get("wcs") if wcs: model.set_fits_wcs(wcs) if uncertainty_type: model.meta.bunit_err = uncertainty_type return model def write(data, path, *args, **kwargs): """ Astropy.io registry compatabilty function to wrap datamodel.savw """ from .model_base import DataModel if not isinstance(data, DataModel): model = DataModel(data) else: model = data if isinstance(path, str): model.save(path, *args, **kwargs) else: raise ValueError("Path to write DataModel was not found") #--------------------------------------- # Astropy NDData compatibility #--------------------------------------- class NDModel(nddata_base.NDDataBase): def my_attribute(self, attr): """ Test if attribute is part of the NDData interface """ properties = frozenset(("data", "mask", "unit", "wcs", "unceratainty")) return attr in properties @property def data(self): """ Read the stored dataset. """ primary_array_name = self.get_primary_array_name() if primary_array_name: primary_array = self.__getattr__(primary_array_name) else: raise AttributeError("No attribute 'data'") return primary_array @data.setter def data(self, value): """ Write the stored dataset. """ primary_array_name = self.get_primary_array_name() if not primary_array_name: primary_array_name = 'data' properties.ObjectNode.__setattr__(self, primary_array_name, value) @property def mask(self): """ Read the mask for the dataset. """ return self.__getattr__('dq') @mask.setter def mask(self, value): """ Write the mask for the dataset. """ properties.ObjectNode.__setattr__(self, 'dq', value) @property def unit(self): """ Read the units for the dataset. """ try: val = self.meta.bunit_data except AttributeError: val = None return val @unit.setter def unit(self, value): """ Write the units for the dataset. """ self.meta.bunit_data = value @property def wcs(self): """ Read the world coordinate system (WCS) for the dataset. """ return self.get_fits_wcs() @wcs.setter def wcs(self, value): """ Write the world coordinate system (WCS) to the dataset. """ return self.set_fits_wcs(value) @property def meta(self): """ Read additional meta information about the dataset. """ return self.__getattr__('meta') @property def uncertainty(self): """ Read the uncertainty in the dataset. """ err = self.err try: val = self.meta.bunit_err except AttributeError: val = None return Uncertainty(err, uncertainty_type=val) @uncertainty.setter def uncertainty(self, value): """ Write the uncertainty in the dataset. """ properties.ObjectNode.__setattr__(self, 'err', value) if hasattr(value, 'uncertainty_type'): self.meta.bunit_err = value.uncertainty_type #--------------------------------------------- # The following classes provide support # for the NDData interface to Datamodels #--------------------------------------------- class MetaNode(properties.ObjectNode, collections.abc.MutableMapping): """ NDData compatibility class for meta node """ def __init__(self, name, instance, schema, ctx): properties.ObjectNode.__init__(self, name, instance, schema, ctx) def _find(self, path): if not path: return self cursor = self._instance schema = self._schema for attr in path: try: cursor = cursor[attr] except KeyError: raise KeyError("'%s'" % '.'.join(path)) schema = properties._get_schema_for_property(schema, attr) key = '.'.join(path) return properties._make_node(key, cursor, schema, self._ctx) def __delitem__(self, key): path = key.split('.') parent = self._find(path[:-1]) try: parent.__delattr__(path[-1]) except KeyError: raise KeyError("'%s'" % key) def __getitem__(self, key): path = key.split('.') return self._find(path) def __len__(self): def recurse(val): n = 0 for subval in val.values(): if isinstance(subval, dict): n += recurse(subval) else: n += 1 return n return recurse(self._instance) def __setitem__(self, key, value): path = key.split('.') parent = self._find(path[:-1]) try: parent.__setattr__(path[-1], value) except KeyError: raise KeyError("'%s'" % key) class Uncertainty(np.ndarray): """ Subclass ndarray to include an additional property, uncertainty_type """ def __new__(cls, err, uncertainty_type=None): # info on how to subclass np.ndarray is at # https://docs.scipy.org/doc/numpy/user/basics.subclassing.html # this code is taken from there obj = np.asarray(err).view(cls) obj.uncertainty_type = uncertainty_type return obj def __array_finalize__(self, obj): if obj is None: return self.uncertainty_type = getattr(obj, 'uncertainty_type', None)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,526
mperrin/jwst
refs/heads/master
/jwst/ami/utils.py
import logging from jwst.datamodels import dqflags import numpy as np import numpy.fft as fft log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) def quadratic(p, x): """ Short Summary ------------- Calculate value of x at minimum or maximum value of y, (value of quadratic function at argument) Parameters ---------- p: numpy array, 3 floats quadratic function: p[0]*x*x + p[1]*x + p[2] x: 1D float array arguments of p() Returns ------- maxx: float value of x at minimum or maximum value of y maxy: float max y = -b^2/4a occurs at x = -b^2/2a fit_val: 1D float array values of quadratic function at arguments in x array """ maxx = -p[1] / (2.0 * p[0]) maxy = -p[1] * p[1] / (4.0 * p[0]) + p[2] fit_val = p[0] * x * x + p[1] * x + p[2] return maxx, maxy, fit_val def makeA(nh): """ Long Summary ------------- Writes the 'NRM matrix' that gets pseudo-inverted to provide (arbitrarily constrained) zero-mean phases of the holes. Algorithm is taken verbatim from Anand's pseudoinverse.py Ax = b where x are the nh hole phases, b the nh(nh-1)/2 fringe phases, and A the NRM matrix Solve for the hole phases: Apinv = np.linalg.pinv(A) Solution for unknown x's: x = np.dot(Apinv, b) Following Noah Gamper's convention of fringe phases, for holes 'a b c d e f g', rows of A are (-1 +1 0 0 ...) (0 -1 +1 0 ...) which is implemented in makeA() as: matrixA[row,h2] = -1 matrixA[row,h1] = +1 To change the convention just reverse the signs of the 'ones'. When tested against Alex'' nrm_model.py 'piston_phase' text output of fringe phases, these signs appear to be correct - anand@stsci.edu 12 Nov 2014 Parameters ---------- nh: integer number of holes in NR mask Returns ------- matrixA: 2D float array nh columns, nh(nh-1)/2 rows (eg 21 for nh=7) """ log.debug('-------') log.debug(' makeA:') ncols = (nh * (nh - 1)) // 2 nrows = nh matrixA = np.zeros((ncols, nrows)) row = 0 for h2 in range(nh): for h1 in range(h2 + 1, nh): if h1 >= nh: break else: log.debug(' row: %s, h1: %s, h2: %s', row, h1, h2) matrixA[row, h2] = -1 matrixA[row, h1] = +1 row += 1 log.debug('matrixA:') log.debug(' %s', matrixA) return matrixA def fringes2pistons(fringephases, nholes): """ Short Summary ------------- For nrm_model.py to use to extract pistons out of fringes, given its hole bookkeeping, which apparently matches that of this module, and is the same as Noah Gamper's. Parameters ---------- fringephases: 1D integer array fringe phases nholes: integer number of holes Returns ------- np.dot(Apinv, fringephases): 1D integer array pistons in same units as fringe phases """ Anrm = makeA(nholes) Apinv = np.linalg.pinv(Anrm) return -np.dot(Apinv, fringephases) def rebin(a=None, rc=(2, 2)): """ Short Summary ------------- Perform simple-minded flux-conserving binning using specified binning kernel, clipping trailing size mismatch: eg a 10x3 array binned by 3 results in a 3x1 array Parameters ---------- a: 2D float array input array to bin rc: 2D float array binning kernel Returns ------- binned_arr: float array binned array """ binned_arr = krebin(a, (a.shape[0] // rc[0], a.shape[1] // rc[1])) return binned_arr def krebin(a, shape): """ Short Summary ------------- Klaus P's fastrebin from web Parameters ---------- a: 2D float array input array to rebin shape: tuple (integer, integer) dimensions of array 'a' binned down by dimensions of binning kernel Returns ------- reshaped_a: 2D float array reshaped input array """ sh = shape[0], a.shape[0] // shape[0], shape[1], a.shape[1] // shape[1] reshaped_a = a.reshape(sh).sum(-1).sum(1) return reshaped_a def rcrosscorrelate(a=None, b=None): """ Short Summary ------------- Calculate cross correlation of two identically-shaped real arrays Parameters ---------- a: 2D float array first input array b: 2D float array second input array Returns ------- c.real.copy(): real part of array that is the correlation of the two input arrays. """ c = crosscorrelate(a=a, b=b)/(np.sqrt((a*a).sum())*np.sqrt((b*b).sum())) return c.real.copy() def crosscorrelate(a=None, b=None): """ Short Summary ------------- Calculate cross correlation of two identically-shaped real or complex arrays Parameters ---------- a: 2D complex float array first input array b: 2D complex float array second input array Returns ------- fft.fftshift(c) complex array that is the correlation of the two input arrays. """ if a.shape != b.shape: log.critical('crosscorrelate: need identical arrays') return None fac = np.sqrt(a.shape[0] * a.shape[1]) A = fft.fft2(a) / fac B = fft.fft2(b) / fac c = fft.ifft2(A * B.conj()) * fac * fac log.debug('----------------') log.debug(' crosscorrelate:') log.debug(' a: %s:', a) log.debug(' A: %s:', A) log.debug(' b: %s:', b) log.debug(' B: %s:', B) log.debug(' c: %s:', c) log.debug(' a.sum(): %s:', a.sum()) log.debug(' b.sum(): %s:', b.sum()) log.debug(' c.sum(): %s:', c.sum()) log.debug(' a.sum()*b.sum(): %s:', a.sum() * b.sum()) log.debug(' c.sum().real: %s:', c.sum().real) log.debug(' a.sum()*b.sum()/c.sum().real: %s:', a.sum()*b.sum()/c.sum().real) return fft.fftshift(c) def findmax(mag, vals, mid=1.0): """ Short Summary ------------- Fit a quadratic to the given input arrays mag and vals, and calculate the value of mag at the extreme value of vals. Parameters ---------- mag: 1D float array array for abscissa vals: 1D float array array for ordinate mid: float midpoint of range Returns ------- maxx: float value of mag at the extreme value of vals maxy: float value of vals corresponding to maxx """ p = np.polyfit(mag, vals, 2) fitr = np.arange(0.95 * mid, 1.05 * mid, .01) maxx, maxy, fitc = quadratic(p, fitr) return maxx, maxy def pix_median_fill_value(input_array, input_dq_array, bsize, xc, yc): """ Short Summary ------------- For the pixel specified by (xc, yc), calculate the median value of the good values within the box of size bsize neighboring pixels. If any of the box is outside the data, 0 will be returned. Parameters ---------- input_array: ndarray 2D input array to filter input_dq_array: ndarray 2D input data quality array bsize: scalar square box size of the data to extract xc: scalar x position of the data extraction yc: scalar y position of the data extraction Returns ------- median_value: float median value of good values within box of neighboring pixels """ # set the half box size hbox = int(bsize/2) # Extract the region of interest for the data try: data_array = input_array[xc - hbox:xc + hbox, yc - hbox: yc + hbox] dq_array = input_dq_array[xc - hbox:xc + hbox, yc - hbox: yc + hbox] except IndexError: # If the box is outside the data return 0 log.warning('Box for median filter is outside the data.') return 0. wh_good = np.where((np.bitwise_and(dq_array, dqflags.pixel['DO_NOT_USE']) == 0)) filtered_array = data_array[wh_good] median_value = np.nanmedian(filtered_array) if np.isnan(median_value): # If the median fails return 0 log.warning('Median filter returned NaN setting value to 0.') median_value = 0. return median_value def img_median_replace(img_model, box_size): """ Short Summary ------------- Replace bad pixels (either due to a dq value of DO_NOT_USE or having a value of NaN) with the median value of surrounding good pixels. Parameters ---------- img_model: image model containing input array to filter. box_size: scalar box size for the median filter Returns ------- img_model: input image model whose input array has its bad pixels replaced by the median of the surrounding good-value pixels. """ input_data = img_model.data input_dq = img_model.dq num_nan = np.count_nonzero(np.isnan(input_data)) num_dq_bad = np.count_nonzero(input_dq == dqflags.pixel['DO_NOT_USE']) # check to see if any of the pixels are flagged if (num_nan + num_dq_bad > 0): bad_locations = np.where(np.isnan(input_data) | np.equal(input_dq, dqflags.pixel['DO_NOT_USE'])) # fill the bad pixel values with the median of the data in a box region for i_pos in range(len(bad_locations[0])): x_box_pos = bad_locations[0][i_pos] y_box_pos = bad_locations[1][i_pos] median_fill = pix_median_fill_value(input_data, input_dq, box_size, x_box_pos, y_box_pos) input_data[x_box_pos, y_box_pos] = median_fill img_model.data = input_data return img_model
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,527
mperrin/jwst
refs/heads/master
/scripts/set_velocity_aberration.py
#!/usr/bin/env python # Copyright (C) 2010-2011 Association of Universities for Research in Astronomy (AURA) # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above # copyright notice, this list of conditions and the following # disclaimer in the documentation and/or other materials provided # with the distribution. # 3. The name of AURA and its representatives may not be used to # endorse or promote products derived from this software without # specific prior written permission. # THIS SOFTWARE IS PROVIDED BY AURA ``AS IS'' AND ANY EXPRESS OR IMPLIED # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE # DISCLAIMED. IN NO EVENT SHALL AURA BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS # OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND # ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR # TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE # USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH # DAMAGE. ''' This script adds velocity aberration correction information to the FITS files provided to it on the command line (one or more). It assumes the following keywords are present in the file header: JWST_DX (km/sec) JWST_DY (km/sec) JWST_DZ (km/sec) RA_REF (deg) DEC_REF (deg) The keywords added are: VA_SCALE (dimensionless scale factor) It does not currently place the new keywords in any particular location in the header other than what is required by the standard. ''' import astropy.io.fits as fits import logging import math import sys # Configure logging logger = logging.getLogger(__name__) logger.addHandler(logging.NullHandler()) SPEED_OF_LIGHT = 299792.458 # km / s d_to_r = math.pi / 180. def aberration_scale(velocity_x, velocity_y, velocity_z, targ_ra, targ_dec): """Compute the scale factor due to velocity aberration. Parameters ---------- velocity_x, velocity_y, velocity_z: float The components of the velocity of JWST, in km / s with respect to the Sun. These are celestial coordinates, with x toward the vernal equinox, y toward right ascension 90 degrees and declination 0, z toward the north celestial pole. targ_ra, targ_dec: float The right ascension and declination of the target (or some other point, such as the center of a detector). The equator and equinox should be the same as the coordinate system for the velocity. Returns ------- scale_factor: float Multiply the nominal image scale (e.g. in degrees per pixel) by this value to obtain the image scale corrected for the "aberration of starlight" due to the velocity of JWST with respect to the Sun. """ speed = math.sqrt(velocity_x**2 + velocity_y**2 + velocity_z**2) if speed == 0.0: logger.warning('Speed is zero. Forcing scale to 1.0') return 1.0 beta = speed / SPEED_OF_LIGHT gamma = 1. / math.sqrt(1. - beta**2) # [targ_x, targ_y, targ_z] is a unit vector. r_xy = math.cos(targ_dec * d_to_r) # radial distance in xy-plane targ_x = r_xy * math.cos(targ_ra * d_to_r) targ_y = r_xy * math.sin(targ_ra * d_to_r) targ_z = math.sin(targ_dec * d_to_r) dot_prod = (velocity_x * targ_x + velocity_y * targ_y + velocity_z * targ_z) cos_theta = dot_prod / speed # This sin_theta is only valid over the range [0, pi], but so is the # angle between the velocity vector and the direction toward the target. sin_theta = math.sqrt(1. - cos_theta**2) tan_theta_p = sin_theta / (gamma * (cos_theta + beta)) theta_p = math.atan(tan_theta_p) scale_factor = (gamma * (cos_theta + beta)**2 / (math.cos(theta_p)**2 * (1. + beta * cos_theta))) return scale_factor def aberration_offset(velocity_x, velocity_y, velocity_z, targ_ra, targ_dec): """Compute the RA/Dec offsets due to velocity aberration. Parameters ---------- velocity_x, velocity_y, velocity_z: float The components of the velocity of JWST, in km / s with respect to the Sun. These are celestial coordinates, with x toward the vernal equinox, y toward right ascension 90 degrees and declination 0, z toward the north celestial pole. targ_ra, targ_dec: float The right ascension and declination of the target (or some other point, such as the center of a detector). The equator and equinox should be the same as the coordinate system for the velocity. Returns ------- delta_ra, delta_dec: float The offset to be added to the input RA/Dec, in units of radians. """ xdot = velocity_x / SPEED_OF_LIGHT ydot = velocity_y / SPEED_OF_LIGHT zdot = velocity_z / SPEED_OF_LIGHT sin_alpha = math.sin(targ_ra * d_to_r) cos_alpha = math.cos(targ_ra * d_to_r) sin_delta = math.sin(targ_dec * d_to_r) cos_delta = math.cos(targ_dec * d_to_r) delta_ra = (-xdot * sin_alpha + ydot * cos_alpha) / cos_delta delta_dec = (-xdot * cos_alpha * sin_delta - ydot * sin_alpha * sin_delta + zdot * cos_delta) return delta_ra, delta_dec def add_dva(filename): ''' Given the name of a valid partially populated level 1b JWST file, determine the velocity aberration scale factor. It presumes all the accessed keywords are present (see first block). ''' hdulist = fits.open(filename, 'update') pheader = hdulist[0].header sheader = hdulist['SCI'].header jwst_dx = float(pheader['JWST_DX']) jwst_dy = float(pheader['JWST_DY']) jwst_dz = float(pheader['JWST_DZ']) ra_ref = float(sheader['RA_REF']) dec_ref = float(sheader['DEC_REF']) # compute the velocity aberration information scale_factor = aberration_scale(jwst_dx, jwst_dy, jwst_dz, ra_ref, dec_ref) ra_off, dec_off = aberration_offset(jwst_dx, jwst_dy, jwst_dz, ra_ref, dec_ref) # update header pheader['DVA_RA'] = ra_off pheader['DVA_DEC'] = dec_off sheader['VA_SCALE'] = scale_factor hdulist.flush() hdulist.close() if __name__ == '__main__': if len(sys.argv) <= 1: raise ValueError('missing filename argument(s)') for filename in sys.argv[1:]: add_dva(filename)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,528
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_spec2.py
"""Test aspects of Spec2Pipline""" import subprocess import pytest from ci_watson.artifactory_helpers import get_bigdata from jwst.assign_wcs.util import NoDataOnDetectorError from jwst.pipeline import Spec2Pipeline @pytest.mark.bigdata def test_nrs2_nodata_api(envopt, _jail): """ Regression test of handling NRS2 detector that has no data.\ """ # Only need to ensure that assing_wcs is run. # This still will fail and should cause the pipeline to halt. step = Spec2Pipeline() step.assign_wcs.skip = False with pytest.raises(NoDataOnDetectorError): step.run(get_bigdata('jwst-pipeline', envopt, 'nirspec', 'test_assignwcs', 'jw84700006001_02101_00001_nrs2_rate.fits' )) @pytest.mark.bigdata def test_nrs2_nodata_strun(envopt, _jail): """Ensure that the appropriate exit status is returned from strun""" data_file = get_bigdata('jwst-pipeline', envopt, 'nirspec', 'test_assignwcs', 'jw84700006001_02101_00001_nrs2_rate.fits' ) cmd = [ 'strun', 'jwst.pipeline.Spec2Pipeline', data_file, '--steps.assign_wcs.skip=false' ] status = subprocess.run(cmd) assert status.returncode == 64
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,529
mperrin/jwst
refs/heads/master
/jwst/datamodels/tests/test_filetype.py
import pytest from ..filetype import check SUPPORTED_EXTS = (('fits', 'fits'), ('json', 'asn'), ('asdf', 'asdf')) # (ext, expected filetype) @pytest.fixture(params=SUPPORTED_EXTS) def input_file(request): return f'test_file.{request.param[0]}', request.param[-1] @pytest.fixture(params=['stpipe.MyPipeline.fits', 'stpipe.MyPipeline.fits.gz']) def pipeline_file(request): return request.param def test_check_on_str_init(input_file): filename, expected = input_file filetype = check(filename) assert filetype == expected def test_check_fails_on_unsupported_ext(): with pytest.raises(ValueError): check('test_file') def test_check_works_for_zipped(input_file): filename, expected = input_file filename += '.gz' # extra zip extension filetype = check(filename) assert filetype == expected def test_check_works_for_pipeline_patters(pipeline_file): assert check(pipeline_file) == 'fits'
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,530
mperrin/jwst
refs/heads/master
/jwst/datamodels/tests/test_history.py
import datetime import numpy as np from astropy.io import fits from astropy.time import Time from asdf.tags.core import HistoryEntry from .. import DataModel def test_historylist_methods(): m = DataModel() h1 = m.history info = "First entry" h1.append(info) assert h1 == info, "Append new history entry" h2 = m.history assert h2 == info, "Two history lists point to the same object" assert len(h1) == 1, "Length of a history list" entry = h1[0] assert entry["description"] == info, "Get history list item" info += " for real" h1[0] = info assert h1 == info, "Set history list item" del h1[0] assert len(h1) == 0, "Delete history list item" info = ("First entry", "Second_entry", "Third entry") h1.extend(info) assert len(h1) == 3, "Length of extended history list" assert h1 == info, "Contents of extended history list" for entry, item in zip(h1, info): assert entry["description"] == item, "Iterate over history list" h1.clear() assert len(h1) == 0, "Clear history list" def test_history_from_model_to_fits(tmpdir): tmpfits = str(tmpdir.join('tmp.fits')) m = DataModel() m.history = [HistoryEntry({ 'description': 'First entry', 'time': Time(datetime.datetime.now())})] m.history.append(HistoryEntry({ 'description': 'Second entry', 'time': Time(datetime.datetime.now()) })) m.save(tmpfits) with fits.open(tmpfits, memmap=False) as hdulist: assert list(hdulist[0].header['HISTORY']) == ["First entry", "Second entry"] with DataModel(tmpfits) as m2: m2 = DataModel() m2.update(m) m2.history = m.history assert m2.history == [{'description': "First entry"}, {'description': "Second entry"}] m2.save(tmpfits) with fits.open(tmpfits, memmap=False) as hdulist: assert list(hdulist[0].header['HISTORY']) == ["First entry", "Second entry"] def test_history_from_fits(tmpdir): tmpfits = str(tmpdir.join('tmp.fits')) header = fits.Header() header['HISTORY'] = "First entry" header['HISTORY'] = "Second entry" fits.writeto(tmpfits, np.array([]), header, overwrite=True) with DataModel(tmpfits) as m: assert m.history == [{'description': 'First entry'}, {'description': 'Second entry'}] del m.history[0] m.history.append(HistoryEntry({'description': "Third entry"})) assert m.history == [{'description': "Second entry"}, {'description': "Third entry"}] m.save(tmpfits) with DataModel(tmpfits) as m: assert m.history == [{'description': "Second entry"}, {'description': "Third entry"}]
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,531
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py
import pytest from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step @pytest.mark.bigdata class TestImage3Pipeline1(BaseJWSTTest): """Regression test definitions for CALIMAGE3 pipeline. Regression test of calwebb_image3 pipeline on NIRCam simulated long-wave data. """ input_loc = 'nircam' ref_loc = ['test_calimage3', 'truth'] test_dir = 'test_calimage3' def test_image3_pipeline1(self): asn_name = "mosaic_long_asn.json" asn_file = self.get_data('test_calimage3', asn_name) for file in raw_from_asn(asn_file): self.get_data('test_calimage3', file) collect_pipeline_cfgs('config') args = [ 'config/calwebb_image3.cfg', asn_file, '--steps.tweakreg.skip=True', ] Step.from_cmdline(args) self.ignore_keywords += ['NAXIS1', 'TFORM*'] self.ignore_fields = self.ignore_keywords self.rtol = 0.0001 outputs = [('nrca5_47Tuc_subpix_dither1_newpos_a3001_crf.fits', 'nrca5_47Tuc_subpix_dither1_newpos_cal-a3001_ref.fits'), ('mosaic_long_i2d.fits', 'mosaic_long_i2d_ref.fits'), ('mosaic_long_cat.ecsv', 'mosaic_long_cat_ref.ecsv'), ] self.compare_outputs(outputs) def test_image3_pipeline2(self): """Regression test definitions for CALIMAGE3 pipeline. Regression test of calwebb_image3 pipeline on NIRCam simulated long-wave data with a 6-point dither. """ asn_file = self.get_data(self.test_dir, "jw10002-o001_20171116t191235_image3_002_asn.json") for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) collect_pipeline_cfgs('config') args = [ 'config/calwebb_image3.cfg', asn_file, '--steps.tweakreg.kernel_fwhm=2', '--steps.tweakreg.snr_threshold=5', '--steps.tweakreg.enforce_user_order=True', '--steps.tweakreg.searchrad=10', '--steps.tweakreg.fitgeometry=rscale', ] Step.from_cmdline(args) self.ignore_keywords += ['NAXIS1', 'TFORM*'] self.ignore_fields = self.ignore_keywords self.rtol = 0.0001 outputs = [('jw10002001001_01101_00004_nrcblong_o001_crf.fits', 'jw10002001001_01101_00004_nrcblong_o001_crf_ref.fits'), ('jw10002-o001_t002_nircam_f444w_i2d.fits', 'jw10002-o001_t002_nircam_f444w_i2d_ref.fits'), ('jw10002-o001_t002_nircam_f444w_cat.ecsv', 'jw10002-o001_t002_nircam_f444w_cat_ref.ecsv'), ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,532
mperrin/jwst
refs/heads/master
/jwst/stpipe/__init__.py
from .step import Step from .pipeline import Pipeline from .linear_pipeline import LinearPipeline __all__ = ['Step', 'Pipeline', 'LinearPipeline']
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,533
mperrin/jwst
refs/heads/master
/jwst/assign_wcs/tests/test_schemas.py
from astropy.modeling import models from astropy import units as u from jwst.datamodels import DistortionModel def test_distortion_schema(tmpdir): """Make sure DistortionModel roundtrips""" m = models.Shift(1) & models.Shift(2) dist = DistortionModel(model=m, input_units=u.pixel, output_units=u.arcsec) dist.meta.instrument.name = "NIRCAM" dist.meta.instrument.detector = "NRCA1" dist.meta.instrument.p_pupil = "F162M|F164N|CLEAR|" dist.meta.instrument.pupil = "F162M" dist.meta.exposure.p_exptype = "NRC_IMAGE|NRC_TSIMAGE|NRC_FLAT|NRC_LED|NRC_WFSC|" dist.meta.exposure.type = "NRC_IMAGE" dist.meta.psubarray = "FULL|SUB64P|SUB160)|SUB160P|SUB320|SUB400P|SUB640|" dist.meta.subarray.name = "FULL" path = str(tmpdir.join("test_dist.asdf")) dist.save(path) with DistortionModel(path) as dist1: assert dist1.meta.instrument.p_pupil == dist.meta.instrument.p_pupil assert dist1.meta.instrument.pupil == dist.meta.instrument.pupil assert dist1.meta.exposure.p_exptype == dist.meta.exposure.p_exptype assert dist1.meta.exposure.type == dist.meta.exposure.type assert dist1.meta.psubarray == dist.meta.psubarray assert dist1.meta.subarray.name == dist.meta.subarray.name
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,534
mperrin/jwst
refs/heads/master
/jwst/lib/tests/test_s3_utils.py
import pytest from jwst.lib import s3_utils from . import helpers @pytest.fixture def s3_text_file(s3_root_dir): path = str(s3_root_dir.join("test.txt")) with open(path, "w") as text_file: print("foo", file=text_file) return path def test_object_exists(s3_text_file): assert s3_utils.object_exists("s3://test-s3-data/test.txt") is True assert s3_utils.object_exists("s3://test-s3-data/missing.fits") is False assert s3_utils.object_exists("s3://missing-bucket/test.txt") is False def test_get_object(s3_text_file): assert s3_utils.get_object("s3://test-s3-data/test.txt").read() == b"foo\n" def test_get_client(s3_text_file): assert isinstance(s3_utils.get_client(), helpers.MockS3Client) def test_is_s3_uri(s3_text_file): assert s3_utils.is_s3_uri("s3://test-s3-data/test.fits") is True assert s3_utils.is_s3_uri("some/filesystem/path") is False def test_split_uri(s3_text_file): assert s3_utils.split_uri("s3://test-s3-data/key") == ("test-s3-data", "key") assert s3_utils.split_uri("s3://test-s3-data/some/longer/key") == ("test-s3-data", "some/longer/key")
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,535
mperrin/jwst
refs/heads/master
/jwst/wfs_combine/wfs_combine_step.py
#! /usr/bin/env python import os.path as op from ..stpipe import Step from . import wfs_combine __all__ = ["WfsCombineStep"] class WfsCombineStep(Step): """ This step combines pairs of dithered PSF images """ spec = """ do_refine = boolean(default=False) """ def process(self, input_table): # Load the input ASN table asn_table = self.load_as_level3_asn(input_table) num_sets = len(asn_table['products']) self.log.info('Using input table: %s', input_table) self.log.info('The number of pairs of input files: %g', num_sets) # Process each pair of input images listed in the association table for which_set in asn_table['products']: # Get the list of science members in this pair science_members = [ member for member in which_set['members'] if member['exptype'].lower() == 'science' ] infile_1 = science_members[0]['expname'] infile_2 = science_members[1]['expname'] outfile = which_set['name'] # Create the step instance wfs = wfs_combine.DataSet( infile_1, infile_2, outfile, self.do_refine ) # Do the processing output_model = wfs.do_all() # Update necessary meta info in the output output_model.meta.cal_step.wfs_combine = 'COMPLETE' output_model.meta.asn.pool_name = asn_table['asn_pool'] output_model.meta.asn.table_name = op.basename(input_table) # Save the output file self.save_model( output_model, suffix='wfscmb', output_file=outfile, format=False ) return None
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,536
mperrin/jwst
refs/heads/master
/jwst/datamodels/extract1dimage.py
from .model_base import DataModel __all__ = ['Extract1dImageModel'] class Extract1dImageModel(DataModel): """ A data model for the extract_1d reference image array. Parameters __________ data : numpy float32 array 1-D extraction regions array """ schema_url = "http://stsci.edu/schemas/jwst_datamodel/extract1dimage.schema"
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,537
mperrin/jwst
refs/heads/master
/jwst/datamodels/tests/test_storage.py
import numpy as np from .. import util def test_gentle_asarray(): x = np.array([('abc', 1.0)], dtype=[ ('FOO', 'S3'), ('BAR', '>f8')]) new_dtype = [('foo', '|S3'), ('bar', '<f8')] y = util.gentle_asarray(x, new_dtype) assert y['BAR'][0] == 1.0
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,538
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/miri/test_miri_steps.py
import pytest from jwst.tests.base_classes import BaseJWSTTestSteps from jwst.tests.base_classes import pytest_generate_tests # noqa: F401 from jwst.refpix import RefPixStep from jwst.dark_current import DarkCurrentStep from jwst.dq_init import DQInitStep from jwst.extract_1d import Extract1dStep from jwst.flatfield import FlatFieldStep from jwst.fringe import FringeStep from jwst.jump import JumpStep from jwst.lastframe import LastFrameStep from jwst.linearity import LinearityStep from jwst.photom import PhotomStep from jwst.rscd import RSCD_Step from jwst.saturation import SaturationStep from jwst.srctype import SourceTypeStep from jwst.straylight import StraylightStep # Parameterized regression tests for MIRI processing # All tests in this set run with 1 input file and # only generate 1 output for comparison. # @pytest.mark.bigdata class TestMIRISteps(BaseJWSTTestSteps): input_loc = 'miri' params = {'test_steps': [ # test_refpix_miri: refpix step performed on MIRI data dict(input='jw00001001001_01101_00001_MIRIMAGE_saturation.fits', test_dir='test_bias_drift', step_class=RefPixStep, step_pars=dict(use_side_ref_pixels=False, side_smoothing_length=10, side_gain=1.0), output_truth='jw00001001001_01101_00001_MIRIMAGE_bias_drift.fits', output_hdus=[], id='refpix_miri' ), # test_refpix_miri2: refpix step performed on MIRI data dict(input='jw00025001001_01107_00001_MIRIMAGE_saturation.fits', test_dir='test_bias_drift', step_class=RefPixStep, step_pars=dict(use_side_ref_pixels=False, side_smoothing_length=10, side_gain=1.0), output_truth='jw00025001001_01107_00001_MIRIMAGE_bias_drift.fits', output_hdus=[], id='refpix_miri2' ), # test_dark_current_miri: dark current step performed on MIRI data dict(input='jw00001001001_01101_00001_MIRIMAGE_bias_drift.fits', test_dir='test_dark_step', step_class=DarkCurrentStep, step_pars=dict(), output_truth='jw00001001001_01101_00001_MIRIMAGE_dark_current.fits', output_hdus=[], id='dark_current_miri' ), # test_dark_current_miri2: dark current step performed on MIRI data dict(input='jw80600012001_02101_00003_mirimage_lastframe.fits', test_dir='test_dark_step', step_class=DarkCurrentStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_dark.fits', output_hdus=[], id='dark_current_miri2' ), # test_dq_init_miri: dq_init step performed on uncalibrated MIRI data dict(input='jw00001001001_01101_00001_MIRIMAGE_uncal.fits', test_dir='test_dq_init', step_class=DQInitStep, step_pars=dict(), output_truth='jw00001001001_01101_00001_MIRIMAGE_dq_init.fits', output_hdus=[], id='dq_init_miri' ), # test_dq_init_miri2: dq_init step performed on uncalibrated MIRI data dict(input='jw80600012001_02101_00003_mirimage_uncal.fits', test_dir='test_dq_init', step_class=DQInitStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_dqinit.fits', output_hdus=[], id='dq_init_miri2' ), # test_extract1d_miri: extract_1d step performed on MIRI LRS fixed-slit data dict(input='jw00035001001_01101_00001_mirimage_photom.fits', test_dir='test_extract1d', step_class=Extract1dStep, step_pars=dict(suffix='x1d'), output_truth='jw00035001001_01101_00001_mirimage_x1d.fits', output_hdus=[], id='extract1d_miri' ), # test_extract1d_miri2: extract_1d step performed on MIRI LRS slitless data dict(input='jw80600012001_02101_00003_mirimage_photom.fits', test_dir='test_extract1d', step_class=Extract1dStep, step_pars=dict(suffix='x1d'), output_truth='jw80600012001_02101_00003_mirimage_x1d.fits', output_hdus=[], id='extract1d_miri2' ), # test_flat_field_miri: flat_field step performed on MIRI data. dict(input='jw00001001001_01101_00001_MIRIMAGE_assign_wcs.fits', test_dir='test_flat_field', step_class=FlatFieldStep, step_pars=dict(), output_truth='jw00001001001_01101_00001_MIRIMAGE_flat_field.fits', output_hdus=[], id='flat_field_miri' ), # test_flat_field_miri2: flat_field step performed on MIRI data. dict(input='jw80600012001_02101_00003_mirimage_assign_wcs.fits', test_dir='test_flat_field', step_class=FlatFieldStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_flat_field.fits', output_hdus=[], id='flat_field_miri2' ), # test_fringe_miri: fringe performed on MIRI data. dict(input='fringe1_input.fits', test_dir='test_fringe', step_class=FringeStep, step_pars=dict(), output_truth='baseline_fringe1.fits', output_hdus=['primary','sci','err','dq'], id='fringe_miri' ), # test_fringe_miri2: fringe performed on MIRI data. dict(input='fringe2_input.fits', test_dir='test_fringe', step_class=FringeStep, step_pars=dict(), output_truth='baseline_fringe2.fits', output_hdus=['primary','sci','err','dq'], id='fringe_miri2' ), # test_fringe_miri3: fringe performed on MIRI data. dict(input='fringe3_input.fits', test_dir='test_fringe', step_class=FringeStep, step_pars=dict(), output_truth='baseline_fringe3.fits', output_hdus=['primary','sci','err','dq'], id='fringe_miri3' ), # test_jump_miri: jump step performed on MIRI data. dict(input='jw00001001001_01101_00001_MIRIMAGE_linearity.fits', test_dir='test_jump', step_class=JumpStep, step_pars=dict(rejection_threshold=200.0), output_truth='jw00001001001_01101_00001_MIRIMAGE_jump.fits', output_hdus=[], id='jump_miri' ), # test_jump_miri2: jump step performed on MIRI data. dict(input='jw80600012001_02101_00003_mirimage_dark.fits', test_dir='test_jump', step_class=JumpStep, step_pars=dict(rejection_threshold=25.0), output_truth='jw80600012001_02101_00003_mirimage_jump.fits', output_hdus=[], id='jump_miri2' ), # test_lastframe_miri2: lastframe step performed on MIRI data dict(input='jw80600012001_02101_00003_mirimage_rscd.fits', test_dir='test_lastframe', step_class=LastFrameStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_lastframe.fits', output_hdus=[], id='lastframe_miri2' ), # test_linearity_miri: linearity step performed on MIRI data dict(input='jw00001001001_01101_00001_MIRIMAGE_dark_current.fits', test_dir='test_linearity', step_class=LinearityStep, step_pars=dict(), output_truth='jw00001001001_01101_00001_MIRIMAGE_linearity.fits', output_hdus=[], id='linearity_miri' ), # test_linearity_miri2: linearity step performed on MIRI data dict(input='jw80600012001_02101_00003_mirimage_saturation.fits', test_dir='test_linearity', step_class=LinearityStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_linearity.fits', output_hdus=[], id='linearity_miri2' ), # test_photom_miri: photom step performed on MIRI imaging data dict(input='jw00001001001_01101_00001_MIRIMAGE_emission.fits', test_dir='test_photom', step_class=PhotomStep, step_pars=dict(), output_truth='jw00001001001_01101_00001_MIRIMAGE_photom.fits', output_hdus=[], id='photom_miri' ), # test_photom_miri2: photom step performed on MIRI LRS slitless data dict(input='jw80600012001_02101_00003_mirimage_srctype.fits', test_dir='test_photom', step_class=PhotomStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_photom.fits', output_hdus=[], id='photom_miri2' ), # test_rscd_miri2: RSCD step performed on MIRI data dict(input='jw80600012001_02101_00003_mirimage_linearity.fits', test_dir='test_rscd', step_class=RSCD_Step, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_rscd.fits', output_hdus=[], id='rscd_miri' ), # test_saturation_miri: saturation step performed on uncalibrated MIRI data dict(input='jw00001001001_01101_00001_MIRIMAGE_dq_init.fits', test_dir='test_saturation', step_class=SaturationStep, step_pars=dict(), output_truth='jw00001001001_01101_00001_MIRIMAGE_saturation.fits', output_hdus=['primary','sci','err','pixeldq','groupdq'], id='saturation_miri' ), # test_saturation_miri2: saturation step performed on uncalibrated MIRI data dict(input='jw80600012001_02101_00003_mirimage_dqinit.fits', test_dir='test_saturation', step_class=SaturationStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_saturation.fits', output_hdus=[], id='saturation_miri2' ), # test_srctype2: srctype step performed on MIRI LRS slitless data dict(input='jw80600012001_02101_00003_mirimage_flat_field.fits', test_dir='test_srctype', step_class=SourceTypeStep, step_pars=dict(), output_truth='jw80600012001_02101_00003_mirimage_srctype.fits', output_hdus=[], id='srctype_miri' ), # test_straylight1_miri: straylight performed on MIRI IFUSHORT data dict(input='jw80500018001_02101_00002_MIRIFUSHORT_flatfield.fits', test_dir='test_straylight', step_class=StraylightStep, step_pars=dict(), output_truth='jw80500018001_02101_00002_MIRIFUSHORT_straylight.fits', output_hdus=['primary','sci','err','dq'], id='straylight_miri' ), # test_straylight2_miri: straylight performed on MIRI IFULONG data dict(input='jw80500018001_02101_00002_MIRIFULONG_flatfield.fits', test_dir='test_straylight', step_class=StraylightStep, step_pars=dict(), output_truth='jw80500018001_02101_00002_MIRIFULONG_straylight.fits', output_hdus=[], id='straylight_miri2' ), ] }
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,539
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/niriss/test_tso3.py
import pytest from jwst.pipeline import Tso3Pipeline from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestTso3Pipeline(BaseJWSTTest): input_loc = 'niriss' ref_loc = ['test_caltso3', 'truth'] test_dir = 'test_caltso3' def test_tso3_pipeline_nis(self): """Regression test of calwebb_tso3 on NIRISS SOSS simulated data. """ asn_file = self.get_data(self.test_dir, "jw87600-a3001_20170527t111213_tso3_001_asn.json") for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) Tso3Pipeline.call(asn_file) outputs = [ # Compare level-2c product ('jw87600024001_02101_00001_nis_a3001_crfints.fits', 'jw87600-a3001_t1_niriss_clear-gr700xd_crfints_ref.fits', ['primary', 'sci', 'dq', 'err']), # Compare level-3 product ('jw87600-a3001_t1_niriss_clear-gr700xd_x1dints.fits', 'jw87600-a3001_t1_niriss_clear-gr700xd_x1dints_ref.fits', ['primary', 'extract1d']), ('jw87600-a3001_t1_niriss_clear-gr700xd_whtlt.ecsv', 'jw87600-a3001_t1_niriss_clear-gr700xd_whtlt_ref.ecsv'), ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,540
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/miri/test_mrs_spec3.py
import pytest from jwst.pipeline.calwebb_spec3 import Spec3Pipeline from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestSpec3Pipeline(BaseJWSTTest): input_loc = 'miri' ref_loc = ['mrs_calspec3', 'truth'] test_dir = 'mrs_calspec3' rtol = 0.000001 def test_spec3_pipeline1(self): """ Regression test of calwebb_spec3 pipeline on simulated MIRI MRS dithered data. """ asn_file = self.get_data(self.test_dir, 'test_asn4.json') for file in raw_from_asn(asn_file): self.get_data(self.test_dir, file) step = Spec3Pipeline() step.save_bsub = False step.mrs_imatch.suffix = 'mrs_imatch' step.mrs_imatch.bkg_degree = 1 step.mrs_imatch.subtract = False step.outlier_detection.skip = True step.output_use_model = True step.resample_spec.save_results = True step.resample_spec.suffix = 's2d' step.cube_build.save_results = True step.cube_build.suffix = 's3d' step.extract_1d.save_results = True step.extract_1d.suffix = 'x1d' step.run(asn_file) outputs = [(# Compare cube product 1 'det_image_ch1-short_s3d.fits', 'det_image_ch1-short_s3d_ref.fits', ['primary', 'sci', 'err', 'dq', 'wmap']), (# Compare cube product 2 'det_image_ch2-short_s3d.fits', 'det_image_ch2-short_s3d_ref.fits', ['primary', 'sci', 'err', 'dq', 'wmap']), (# Compare x1d product 1 'det_image_ch1-short_x1d.fits', 'det_image_ch1-short_x1d_ref.fits', ['primary', 'extract1d']), (# Compare x1d product 2 'det_image_ch2-short_x1d.fits', 'det_image_ch2-short_x1d_ref.fits', ['primary', 'extract1d']) ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,541
mperrin/jwst
refs/heads/master
/jwst/pipeline/tests/test_calwebspec2.py
import pytest from ..calwebb_spec2 import Spec2Pipeline @pytest.fixture(scope='module') def fake_pipeline(): return Spec2Pipeline() def test_filenotfounderror_raised(fake_pipeline, capsys): with pytest.raises(RuntimeError): fake_pipeline.run('file_does_not_extis.fits') captured = capsys.readouterr() assert 'FileNotFoundError' in captured.err
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,542
mperrin/jwst
refs/heads/master
/jwst/ami/ami_analyze.py
# # Module for applying the LG algorithm to an AMI exposure # import logging import warnings import numpy as np from .. import datamodels from .nrm_model import NrmModel from . import webb_psf from . import leastsqnrm from . import utils log = logging.getLogger(__name__) log.setLevel(logging.DEBUG) def apply_LG(input_model, filter_model, oversample, rotation): """ Short Summary ------------- Applies the LG fringe detection algorithm to an AMI image Parameters ---------- input_model: data model object AMI science image to be analyzed filter_model: filter model object filter throughput reference data oversample: integer Oversampling factor rotation: float (degrees) Initial guess at rotation of science image relative to model Returns ------- output_model: Fringe model object Fringe analysis data """ # Supress harmless arithmetic warnings for now warnings.filterwarnings("ignore", ".*invalid value.*", RuntimeWarning) warnings.filterwarnings("ignore", ".*divide by zero.*", RuntimeWarning) # Report the FILTER value for this image log.info('Filter: %s', input_model.meta.instrument.filter) # Load the filter throughput data from the reference file bindown = 12 band = webb_psf.get_webbpsf_filter(filter_model, specbin=bindown) # Set up some params that are needed as input to the LG algorithm: # Search window for rotation fine-tuning rots_deg = np.array((-1.00, -0.5, 0.0, 0.5, 1.00)) # Search range for relative pixel scales relpixscales = np.array((64.2, 64.4, 64.6, 64.8, 65.0, 65.2, 65.4, 65.6, 65.8)) /65.0 # Convert initial rotation guess from degrees to radians rotation = rotation * np.pi / 180.0 # Instantiate the NRM model object jwnrm = NrmModel(mask='jwst', holeshape='hex', pixscale=leastsqnrm.mas2rad(65.), rotate=rotation, rotlist_deg=rots_deg, scallist=relpixscales) # Load the filter bandpass data into the NRM model jwnrm.bandpass = band # Set the oversampling factor in the NRM model jwnrm.over = oversample # Now fit the data in the science exposure # (pixguess is a guess at the pixel scale of the data) # produces a 19x19 image of the fit input_data = input_model.data.astype(np.float64) input_dq = input_model.dq datamodel_img_model = datamodels.ImageModel(data=input_data, dq=input_dq) box_size = 4 new_img_model = utils.img_median_replace(datamodel_img_model, box_size) input_data = new_img_model.data.copy() input_model.data = input_data.astype(np.float64) del datamodel_img_model, new_img_model subarray = input_model.meta.subarray.name.upper() if subarray == 'FULL': # Instead of using the FULL subarray, extract the same region (size and # location) as used by SUB80 to make execution time acceptable xstart = 1045 # / Starting pixel in axis 1 direction ystart = 1 # / Starting pixel in axis 2 direction xsize = 80 # / Number of pixels in axis 1 direction ysize = 80 # / Number of pixels in axis 2 direction xstop = xstart + xsize - 1 ystop = ystart + ysize - 1 jwnrm.fit_image(input_data[ystart-1:ystop, xstart-1:xstop], pixguess=jwnrm.pixel) else: jwnrm.fit_image(input_data, pixguess=jwnrm.pixel) # Construct model image from fitted PSF jwnrm.create_modelpsf() # Reset the warnings filter to its original state warnings.resetwarnings() # Store fit results in output model output_model = datamodels.AmiLgModel(fit_image=jwnrm.modelpsf, resid_image=jwnrm.residual, closure_amp_table=np.asarray(jwnrm.redundant_cas), closure_phase_table=np.asarray(jwnrm.redundant_cps), fringe_amp_table=np.asarray(jwnrm.fringeamp), fringe_phase_table=np.asarray(jwnrm.fringephase), pupil_phase_table=np.asarray(jwnrm.piston), solns_table=np.asarray(jwnrm.soln)) # Copy header keywords from input to output output_model.update(input_model) return output_model
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,543
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py
"""Test calwebb_spec3 against NIRSpec MOS science (MSA)""" from pathlib import Path import pytest from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step from jwst.tests.base_classes import BaseJWSTTest, raw_from_asn @pytest.mark.bigdata class TestSpec3Pipeline(BaseJWSTTest): """Tests for Spec3Pipeline""" input_loc = 'nirspec' ref_loc = ['test_datasets', 'msa', 'sdp_jw95175', 'truth'] test_dir = ['test_datasets', 'msa', 'sdp_jw95175'] def test_nrs_msa_spec3(self): """ Regression test of calwebb_spec3 pipeline performed on NIRSpec MSA data """ cfg_dir = './cfgs' collect_pipeline_cfgs(cfg_dir) asn_file = self.get_data(*self.test_dir, 'single_asn.json') for file in raw_from_asn(asn_file): self.get_data(*self.test_dir, file) args = [ str(Path(cfg_dir) / 'calwebb_spec3.cfg'), asn_file ] Step.from_cmdline(args) # Compare results truths = self.data_glob(*self.ref_loc, glob='*.fits') outputs = [ (Path(output_file).name, ) * 2 for output_file in truths ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,544
mperrin/jwst
refs/heads/master
/jwst/tests_nightly/general/nirspec/test_pipelines.py
import pytest from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step from jwst.pipeline import DarkPipeline from jwst.pipeline import Spec2Pipeline from jwst.tests.base_classes import BaseJWSTTest @pytest.mark.bigdata class TestNIRSpecPipelines(BaseJWSTTest): input_loc = 'nirspec' ref_loc = ['test_pipelines', 'truth'] test_dir = 'test_pipelines' def test_nirspec_dark_pipeline(self): """ Regression test of calwebb_dark pipeline performed on NIRSpec raw data. """ input_file = self.get_data(self.test_dir, 'jw84500013001_02103_00003_NRS1_uncal.fits') pipe = DarkPipeline() pipe.suffix = 'dark' pipe.ipc.skip = True pipe.refpix.odd_even_columns = True pipe.refpix.use_side_ref_pixels = True pipe.refpix.side_smoothing_length = 11 pipe.refpix.side_gain = 1.0 pipe.refpix.odd_even_rows = True pipe.output_file = 'jw84500013001_02103_00003_NRS1_uncal.fits' pipe.run(input_file) outputs = [('jw84500013001_02103_00003_NRS1_dark.fits', 'jw84500013001_02103_00003_NRS1_dark_ref.fits', ['primary','sci','err','pixeldq','groupdq'])] self.compare_outputs(outputs) def test_nrs_fs_brightobj_spec2(self): """ Regression test of calwebb_spec2 pipeline performed on NIRSpec fixed-slit data that uses the NRS_BRIGHTOBJ mode (S1600A1 slit). """ input_file = self.get_data(self.test_dir, 'jw84600042001_02101_00001_nrs2_rateints.fits') collect_pipeline_cfgs() args = [ 'calwebb_tso-spec2.cfg', input_file ] Step.from_cmdline(args) outputs = [('jw84600042001_02101_00001_nrs2_calints.fits', 'jw84600042001_02101_00001_nrs2_calints_ref.fits'), ('jw84600042001_02101_00001_nrs2_x1dints.fits', 'jw84600042001_02101_00001_nrs2_x1dints_ref.fits') ] self.compare_outputs(outputs) def test_nrs_msa_spec2(self): """ Regression test of calwebb_spec2 pipeline performed on NIRSpec MSA data. """ input = 'f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod.fits' input_file = self.get_data(self.test_dir, input) self.get_data(self.test_dir, 'jw95065006001_0_short_msa.fits') # define step for use in test step = Spec2Pipeline() step.save_results = True step.save_bsub = False step.output_use_model = True step.resample_spec.save_results = True step.extract_1d.save_results = True step.extract_1d.smoothing_length = 0 step.extract_1d.bkg_order = 0 step.run(input_file) outputs = [('f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_cal.fits', 'f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_cal_ref.fits'), ('f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_s2d.fits', 'f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_s2d_ref.fits'), ('f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_x1d.fits', 'f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_x1d_ref.fits') ] self.compare_outputs(outputs) def test_nrs_msa_spec2b(self): """ Regression test of calwebb_spec2 pipeline performed on NIRSpec MSA data, including barshadow correction. """ input = 'jw95065_nrs_msaspec_barshadow.fits' input_file = self.get_data(self.test_dir, input) self.get_data(self.test_dir, 'jwst_nirspec_shutters_barshadow.fits') step = Spec2Pipeline() step.output_file='jw95065_nrs_msaspec_barshadow_cal.fits' step.save_bsub = False step.save_results = True step.resample_spec.save_results = True step.extract_1d.save_results = True step.run(input_file) outputs = [('jw95065_nrs_msaspec_barshadow_cal.fits', 'jw95065_nrs_msaspec_barshadow_cal_ref.fits'), ('jw95065_nrs_msaspec_barshadow_s2d.fits', 'jw95065_nrs_msaspec_barshadow_s2d_ref.fits'), ('jw95065_nrs_msaspec_barshadow_x1d.fits', 'jw95065_nrs_msaspec_barshadow_x1d_ref.fits') ] self.compare_outputs(outputs)
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,545
mperrin/jwst
refs/heads/master
/jwst/associations/tests/test_constraints.py
"""Constraint Tests""" import pytest from ..lib.constraint import ( Constraint, SimpleConstraint, SimpleConstraintABC, ) def test_simpleconstraint_reprocess_match(): """Test options for reprocessing""" sc = SimpleConstraint( value='my_value', reprocess_on_match=True ) match, reprocess = sc.check_and_set('my_value') assert match assert len(reprocess) def test_simpleconstraint_reprocess_nomatch(): """Test options for reprocessing""" sc = SimpleConstraint( value='my_value', reprocess_on_fail=True ) match, reprocess = sc.check_and_set('bad_value') assert not match assert len(reprocess) def test_constraint_reprocess_match(): """Test options for reprocessing""" sc = SimpleConstraint(value='my_value') c = Constraint([sc], reprocess_on_match=True) match, reprocess = c.check_and_set('my_value') assert match assert len(reprocess) def test_constraint_reprocess_nomatch(): """Test options for reprocessing""" sc = SimpleConstraint(value='my_value') c = Constraint([sc], reprocess_on_fail=True) match, reprocess = c.check_and_set('bad_value') assert not match assert len(reprocess) def test_abc(): """Test ABC istelf""" with pytest.raises(TypeError): SimpleConstraintABC() def test_simpleconstraint(): """Test initialization""" # Basic initialization c = SimpleConstraint() assert c.value is None assert c.force_unique assert c.test == c.eq # Parameter initialization c = SimpleConstraint(value='my_value') assert c.value == 'my_value' # Dict initialization c = SimpleConstraint({'value': 'my_value'}) assert c.value == 'my_value' def test_simpleconstraint_checkset(): """Test check_and_set""" # Check and set. c = SimpleConstraint() match, reprocess = c.check_and_set('my_value') assert match assert c.value == 'my_value' assert len(reprocess) == 0 # Non-match c = SimpleConstraint(value='my_value') match, reprocess = c.check_and_set('bad_value') assert not match assert c.value == 'my_value' assert len(reprocess) == 0 # Don't force unique c = SimpleConstraint(force_unique=False) match, reprocess = c.check_and_set('my_value') assert match assert c.value is None assert len(reprocess) == 0 def test_constraint_default(): """Test constraint operations""" sc1 = SimpleConstraint() sc2 = SimpleConstraint() c = Constraint([sc1, sc2]) match, reprocess = c.check_and_set('my_value') assert match for constraint in c.constraints: assert constraint.value == 'my_value' def test_invalid_init(): with pytest.raises(TypeError): Constraint('bad init') def test_constraint_all(): """Test the all operation""" sc1 = SimpleConstraint(value='value_1') sc2 = SimpleConstraint(value='value_2') c = Constraint([sc1, sc2]) match, reprocess = c.check_and_set('value_1') assert not match def test_constraint_any_basic(): """Test the all operation""" sc1 = SimpleConstraint(value='value_1') sc2 = SimpleConstraint(value='value_2') c = Constraint([sc1, sc2], reduce=Constraint.any) match, reprocess = c.check_and_set('value_1') assert match match, reprocess = c.check_and_set('value_2') assert match match, reprocess = c.check_and_set('value_3') assert not match def test_constraint_any_remember(): """Ensure that any doesn't forget other or propositions""" sc1 = SimpleConstraint(value='value_1') sc2 = SimpleConstraint(value='value_2') c = Constraint([sc1, sc2], reduce=Constraint.any) match, reprocess = c.check_and_set('value_1') assert match match, reprocess = c.check_and_set('value_2') assert match match, reprocess = c.check_and_set('value_1') assert match match, reprocess = c.check_and_set('value_3') assert not match def test_iteration(): """Test various iterations""" sc = SimpleConstraint() for idx in sc: assert isinstance(idx, SimpleConstraint) c = Constraint([sc, sc]) count = 0 for idx in c: assert isinstance(idx, SimpleConstraint) count += 1 assert count == 2 c = Constraint([ Constraint([sc, sc]), Constraint([sc, sc]) ]) count = 0 for idx in c: assert isinstance(idx, SimpleConstraint) count += 1 assert count == 4 # Not 6 def test_name_index(): """Test for name indexing""" sc1 = SimpleConstraint(name='sc1', value='value1') sc2 = SimpleConstraint(name='sc2', value='value2') c1 = Constraint([sc1, sc2]) assert c1['sc1'].value assert c1['sc2'].value sc3 = SimpleConstraint(name='sc3', value='value3') sc4 = SimpleConstraint(name='sc4', value='value4') c2 = Constraint([sc3, sc4, c1]) assert c2['sc1'].value assert c2['sc2'].value assert c2['sc3'].value assert c2['sc4'].value with pytest.raises(KeyError): c2['nonexistant'].value with pytest.raises(AttributeError): c2['sc1'].nonexistant def test_copy(): sc1 = SimpleConstraint(name='sc1') sc1_copy = sc1.copy() assert id(sc1) != id(sc1_copy) sc1.check_and_set('value1') assert sc1.value == 'value1' assert sc1_copy.value is None sc1_copy.check_and_set('value2') assert sc1_copy.value == 'value2' assert sc1.value == 'value1'
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}
13,546
mperrin/jwst
refs/heads/master
/jwst/regtest/test_nirspec_mos_spec2.py
import os import pytest from astropy.io.fits.diff import FITSDiff from jwst.pipeline.collect_pipeline_cfgs import collect_pipeline_cfgs from jwst.stpipe import Step @pytest.fixture(scope="module") def run_pipeline(jail, rtdata_module): """Run the calwebb_spec2 pipeline on a single NIRSpec MOS exposure.""" rtdata = rtdata_module # Get the cfg files collect_pipeline_cfgs("config") # Get the MSA metadata file referenced in the input exposure rtdata.get_data("nirspec/mos/jw95065006001_0_short_msa.fits") # Get the input exposure rtdata.get_data("nirspec/mos/f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod.fits") # Run the calwebb_spec2 pipeline; save results from intermediate steps args = ["config/calwebb_spec2.cfg", rtdata.input, "--steps.assign_wcs.save_results=true", "--steps.msa_flagging.save_results=true", "--steps.extract_2d.save_results=true", "--steps.srctype.save_results=true", "--steps.wavecorr.save_results=true", "--steps.flat_field.save_results=true", "--steps.pathloss.save_results=true", "--steps.barshadow.save_results=true"] Step.from_cmdline(args) return rtdata @pytest.mark.bigdata @pytest.mark.parametrize("output",[ "assign_wcs", "msa_flagging", "extract_2d", "wavecorr", "flat_field", "srctype", "pathloss", "barshadow", "cal", "s2d", "x1d"]) def test_nirspec_mos_spec2(run_pipeline, fitsdiff_default_kwargs, output): """Regression test of the calwebb_spec2 pipeline on a NIRSpec MOS exposure.""" # Run the pipeline and retrieve outputs rtdata = run_pipeline rtdata.output = "f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_" + output + ".fits" # Get the truth files rtdata.get_truth(os.path.join("truth/test_nirspec_mos_spec2", "f170lp-g235m_mos_observation-6-c0e0_001_dn_nrs1_mod_" + output + ".fits")) # Compare the results diff = FITSDiff(rtdata.output, rtdata.truth, **fitsdiff_default_kwargs) assert diff.identical, diff.report()
{"/jwst/tests_nightly/general/miri/test_sloperpipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2b.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_nis_wfss_spec2.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_miri_image_detector1.py": ["/jwst/stpipe/__init__.py"], "/jwst/flatfield/flat_field_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_spec2pipelines.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_miri_steps_single.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/tests_nightly/general/nircam/test_wfs_combine.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_masterbackground.py": ["/jwst/stpipe/__init__.py"], "/jwst/regtest/test_nirspec_image2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_calwebb_spec2_nrs_msa.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/pipeline/linear_pipeline.py": ["/jwst/stpipe/__init__.py", "/jwst/flatfield/flat_field_step.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/fgs/test_fgs_sloper_1.py": ["/jwst/tests/base_classes.py"], "/jwst/regtest/test_fgs_guider.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_spec2pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/fgs/test_guider_pipeline.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nircam_steps.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_image2pipeline_2.py": ["/jwst/tests/base_classes.py"], "/jwst/tests/base_classes.py": ["/jwst/tests/compare_outputs.py"], "/jwst/master_background/tests/test_nirspec_corrections.py": ["/jwst/master_background/nirspec_corrections.py"], "/jwst/datamodels/tests/test_fits.py": ["/jwst/datamodels/util.py"], "/jwst/tests_nightly/general/fgs/test_fgs_image2_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mirilrs2_slitless.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/master_background/__init__.py"], "/jwst/stpipe/tests/test_pipeline.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/niriss/test_niriss_steps_single.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_fs_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nircam/test_nrc_image3_1.py": ["/jwst/tests/base_classes.py", "/jwst/stpipe/__init__.py"], "/jwst/stpipe/__init__.py": ["/jwst/stpipe/linear_pipeline.py"], "/jwst/wfs_combine/wfs_combine_step.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/miri/test_miri_steps.py": ["/jwst/tests/base_classes.py", "/jwst/rscd/__init__.py"], "/jwst/tests_nightly/general/niriss/test_tso3.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_mrs_spec3.py": ["/jwst/tests/base_classes.py"], "/jwst/ami/ami_analyze.py": ["/jwst/ami/nrm_model.py"], "/jwst/tests_nightly/general/nirspec/test_nirspec_msa_spec3.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/nirspec/test_pipelines.py": ["/jwst/stpipe/__init__.py", "/jwst/tests/base_classes.py"], "/jwst/regtest/test_nirspec_mos_spec2.py": ["/jwst/stpipe/__init__.py"], "/jwst/tests_nightly/general/nircam/test_coron3_1.py": ["/jwst/tests/base_classes.py"], "/jwst/tests_nightly/general/miri/test_image2pipeline_1.py": ["/jwst/tests/base_classes.py"]}