diff --git a/src/core/pyros_django/seq_submit/models.py b/src/core/pyros_django/seq_submit/models.py index 2398afd..fde7607 100644 --- a/src/core/pyros_django/seq_submit/models.py +++ b/src/core/pyros_django/seq_submit/models.py @@ -17,6 +17,7 @@ import os import sys from typing import Any, List, Tuple, Optional import re +import json # DJANGO imports from django.core.validators import MaxValueValidator, MinValueValidator @@ -317,7 +318,7 @@ class Sequence(models.Model): ('BEST_ELEVATION', 'BEST_ELEVATION'), ('NO_CONSTRAINT', 'NO_CONSTRAINT'), ) - + id = models.BigAutoField(primary_key=True) start_expo_pref = models.CharField(max_length=50, blank=False, null=True, choices=START_EXPO_PREF_CHOICES, default=START_EXPO_PREF_CHOICES[0]) # request = models.ForeignKey( @@ -532,6 +533,7 @@ class ImageManager(models.Manager): return None class Image(models.Model): + id = models.BigAutoField(primary_key=True) plan = models.ForeignKey(Plan, on_delete=models.CASCADE, related_name="images") name = models.CharField(max_length=90, blank=True, null=True) created = models.DateTimeField(blank=True, null=True, auto_now_add=True) @@ -561,23 +563,33 @@ class Image(models.Model): key18 = models.CharField(max_length=45, blank=True, null=True) key19 = models.CharField(max_length=45, blank=True, null=True) key20 = models.CharField(max_length=45, blank=True, null=True) - + coscrval1 = models.FloatField(blank=True, null=True) + coscrval2 = models.FloatField(blank=True, null=True) + sincrval1 = models.FloatField(blank=True, null=True) + sincrval2 = models.FloatField(blank=True, null=True) objects = ImageManager() def set_attribute_and_save(self, *args, **kwargs): img_obj = kwargs.get("img_obj") plan_id = kwargs.get("plan_id") - self.plan_id = plan_id + save = kwargs.get("save") + self.plan = Plan.objects.get(id=plan_id) params = img_obj.naming_get(img_obj.fname) self.date_from_gps = img_obj.getkwd("DATE-OBS") self.fc_name = img_obj.naming() - self.name = os.path.basename(img_obj.fname) + self.name = img_obj.fname self.abs_path = img_obj.path for index, field in enumerate(params): index += 1 self.__dict__["key" + str(index)] = params[field] file_out = img_obj.join(img_obj.fname) - img_obj.save(file_out) + naxis1 = img_obj.getkwd("NAXIS1") + naxis2 = img_obj.getkwd("NAXIS2") + sky_field_as_json = json.dumps(img_obj._wcs.wcs2skyfield(naxis1, naxis2)) + self.sky_field = sky_field_as_json + # Save as default, if save parameter is passed, save only if is True + if save is None or (save is not None and save): + img_obj.save(file_out) self.save() -- libgit2 0.21.2