Skip to content

Commit

Permalink
Merge pull request #1565 from mfixstsci/update-nirspec-ta-models
Browse files Browse the repository at this point in the history
Update NIRSpec TA Models
  • Loading branch information
mfixstsci authored May 7, 2024
2 parents a728d9c + d0dfba3 commit 7464f7d
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
import os
import logging
from datetime import datetime, timezone, timedelta
from dateutil import parser
from random import randint

import numpy as np
Expand Down Expand Up @@ -467,7 +468,7 @@ def add_time_column(self):

def add_timezone(self, date_str):
"""Method to bypass timezone warning from Django"""
dt_timezone = datetime.fromisoformat(date_str).replace(tzinfo=timezone.utc)
dt_timezone = parser.parse(date_str).replace(tzinfo=timezone.utc)
return dt_timezone

def plt_status(self):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
import os
import logging
from datetime import datetime, timezone, timedelta
from dateutil import parser

import numpy as np
import pandas as pd
Expand Down Expand Up @@ -988,7 +989,7 @@ def update_ta_success_txtfile(self):

def add_timezone(self, date_str):
"""Method to bypass timezone warning from Django"""
dt_timezone = datetime.fromisoformat(date_str).replace(tzinfo=timezone.utc)
dt_timezone = parser.parse(date_str).replace(tzinfo=timezone.utc)
return dt_timezone

def add_wata_data(self):
Expand Down
2 changes: 2 additions & 0 deletions jwql/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,6 +1045,7 @@ class QueryConfigKeys:
MAX_LEN_DIFF_IMAGE = 1000
MAX_LEN_FILENAME = 1000
MAX_LEN_FILTER = 7
MAX_LEN_GENERIC_TEXT = 100
MAX_LEN_GRATING = 40
MAX_LEN_INSTRUMENT = 7
MAX_LEN_MNEMONIC = 40
Expand All @@ -1059,3 +1060,4 @@ class QueryConfigKeys:
MAX_LEN_TIME = 50
MAX_LEN_TYPE = 40
MAX_LEN_USER = 50
MAX_LEN_VISIT = 30
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Generated by Django 4.2.6 on 2024-05-02 16:16
# Generated by Django 4.2.6 on 2024-05-07 15:15

import django.contrib.postgres.fields
from django.db import migrations, models
Expand All @@ -17,8 +17,8 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('filename', models.CharField(blank=True, max_length=1000, null=True)),
('date_obs', models.DateTimeField(blank=True, null=True)),
('visit_id', models.CharField(blank=True, null=True)),
('tafilter', models.CharField(blank=True, null=True)),
('visit_id', models.CharField(blank=True, max_length=30, null=True)),
('tafilter', models.CharField(blank=True, max_length=7, null=True)),
('detector', models.CharField(blank=True, max_length=40, null=True)),
('readout', models.CharField(blank=True, max_length=40, null=True)),
('subarray', models.CharField(blank=True, max_length=40, null=True)),
Expand All @@ -44,10 +44,10 @@ class Migration(migrations.Migration):
('samroll', models.FloatField(blank=True, null=True)),
('box_peak_value', django.contrib.postgres.fields.ArrayField(base_field=models.FloatField(), size=None)),
('reference_star_mag', django.contrib.postgres.fields.ArrayField(base_field=models.FloatField(), size=None)),
('convergence_status', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(), size=None)),
('convergence_status', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=100, null=True), size=None)),
('reference_star_number', django.contrib.postgres.fields.ArrayField(base_field=models.IntegerField(), size=None)),
('lsf_removed_status', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(), size=None)),
('lsf_removed_reason', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(), size=None)),
('lsf_removed_status', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=100, null=True), size=None)),
('lsf_removed_reason', django.contrib.postgres.fields.ArrayField(base_field=models.CharField(blank=True, max_length=100, null=True), size=None)),
('lsf_removed_x', django.contrib.postgres.fields.ArrayField(base_field=models.FloatField(), size=None)),
('lsf_removed_y', django.contrib.postgres.fields.ArrayField(base_field=models.FloatField(), size=None)),
('planned_v2', django.contrib.postgres.fields.ArrayField(base_field=models.FloatField(), size=None)),
Expand All @@ -67,10 +67,10 @@ class Migration(migrations.Migration):
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('filename', models.CharField(blank=True, max_length=1000, null=True)),
('date_obs', models.DateTimeField(blank=True, null=True)),
('visit_id', models.CharField(blank=True, null=True)),
('tafilter', models.CharField(blank=True, null=True)),
('visit_id', models.CharField(blank=True, max_length=30, null=True)),
('tafilter', models.CharField(blank=True, max_length=7, null=True)),
('readout', models.CharField(blank=True, max_length=40, null=True)),
('ta_status', models.CharField(blank=True, null=True)),
('ta_status', models.CharField(blank=True, max_length=100, null=True)),
('star_name', models.IntegerField(blank=True, null=True)),
('star_ra', models.FloatField(blank=True, null=True)),
('star_dec', models.FloatField(blank=True, null=True)),
Expand Down
28 changes: 17 additions & 11 deletions jwql/website/apps/jwql/monitor_models/ta.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
from jwql.utils.constants import (
MAX_LEN_APERTURE,
MAX_LEN_DETECTOR,
MAX_LEN_TIME,
MAX_LEN_FILENAME,
MAX_LEN_FILTER,
MAX_LEN_GENERIC_TEXT,
MAX_LEN_INSTRUMENT,
MAX_LEN_NGROUPS,
MAX_LEN_NINTS,
MAX_LEN_PATH,
MAX_LEN_READPATTERN,
MAX_LEN_SUBARRAY,
MAX_LEN_VISIT,
)


Expand Down Expand Up @@ -97,10 +97,10 @@ class Meta:
class NIRSpecWataStats(models.Model):
filename = models.CharField(max_length=MAX_LEN_FILENAME, blank=True, null=True)
date_obs = models.DateTimeField(blank=True, null=True)
visit_id = models.CharField(blank=True, null=True)
tafilter = models.CharField(blank=True, null=True)
visit_id = models.CharField(max_length=MAX_LEN_VISIT, blank=True, null=True)
tafilter = models.CharField(max_length=MAX_LEN_FILTER, blank=True, null=True)
readout = models.CharField(max_length=MAX_LEN_READPATTERN, blank=True, null=True)
ta_status = models.CharField(blank=True, null=True)
ta_status = models.CharField(max_length=MAX_LEN_GENERIC_TEXT, blank=True, null=True)
star_name = models.IntegerField(blank=True, null=True)
star_ra = models.FloatField(blank=True, null=True)
star_dec = models.FloatField(blank=True, null=True)
Expand Down Expand Up @@ -142,8 +142,8 @@ class Meta:
class NIRSpecMsataStats(models.Model):
filename = models.CharField(max_length=MAX_LEN_FILENAME, blank=True, null=True)
date_obs = models.DateTimeField(blank=True, null=True)
visit_id = models.CharField(blank=True, null=True)
tafilter = models.CharField(blank=True, null=True)
visit_id = models.CharField(max_length=MAX_LEN_VISIT, blank=True, null=True)
tafilter = models.CharField(max_length=MAX_LEN_FILTER, blank=True, null=True)
detector = models.CharField(max_length=MAX_LEN_DETECTOR, blank=True, null=True)
readout = models.CharField(max_length=MAX_LEN_READPATTERN, blank=True, null=True)
subarray = models.CharField(max_length=MAX_LEN_SUBARRAY, blank=True, null=True)
Expand All @@ -169,10 +169,16 @@ class NIRSpecMsataStats(models.Model):
samroll = models.FloatField(blank=True, null=True)
box_peak_value = ArrayField(models.FloatField())
reference_star_mag = ArrayField(models.FloatField())
convergence_status = ArrayField(models.CharField())
convergence_status = ArrayField(
models.CharField(max_length=MAX_LEN_GENERIC_TEXT, blank=True, null=True)
)
reference_star_number = ArrayField(models.IntegerField())
lsf_removed_status = ArrayField(models.CharField())
lsf_removed_reason = ArrayField(models.CharField())
lsf_removed_status = ArrayField(
models.CharField(max_length=MAX_LEN_GENERIC_TEXT, blank=True, null=True)
)
lsf_removed_reason = ArrayField(
models.CharField(max_length=MAX_LEN_GENERIC_TEXT, blank=True, null=True)
)
lsf_removed_x = ArrayField(models.FloatField())
lsf_removed_y = ArrayField(models.FloatField())
planned_v2 = ArrayField(models.FloatField())
Expand Down

0 comments on commit 7464f7d

Please sign in to comment.