srg/astrobasis/models.py
2024-04-26 12:43:00 +03:00

883 lines
33 KiB
Python

from django.db import models
from datetime import datetime
#from django.utils.timezone import localdate, localtime
#from monthplan.models import Survey
from math import isfinite, sqrt
from django import forms
import urllib.parse
# Create your models here.
# https://docs.djangoproject.com/en/3.0/howto/custom-lookups/
from django.db.models import Transform
class AbsoluteValue(Transform):
lookup_name = 'abs'
function = 'ABS'
models.FloatField.register_lookup(AbsoluteValue)
class GLIMPSE(models.Model):
"""
GLIMPSE Source Catalog (I + II + 3D) (IPAC 2008)
Only high-reliability sources are loaded (marked as C)
"""
healpix = models.BigIntegerField(db_index=True, default=0, null=True)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
error_radius = models.FloatField(default=0.5)
""" additional field for cross-match """
name = models.CharField(max_length=17,blank=True, default='')
twomass = models.CharField(max_length=16,blank=True, default='')
jmag = models.FloatField(default=0.0,null=True)
hmag = models.FloatField(default=0.0,null=True)
kmag = models.FloatField(default=0.0,null=True)
b1mag = models.FloatField(default=0.0,null=True)
""" 3.6um IRAC (Band 1) magnitude """
e_b1mag = models.FloatField(default=0.0,null=True)
""" 1-{sigma} error on 3.6mag """
b2mag = models.FloatField(default=0.0,null=True)
""" 4.5um IRAC (Band 2) magnitude """
e_b2mag = models.FloatField(default=0.0,null=True)
""" 1-{sigma} error on 4.5mag """
b3mag = models.FloatField(default=0.0,null=True)
""" 5.8um IRAC (Band 1) magnitude """
e_b3mag = models.FloatField(default=0.0,null=True)
""" 1-{sigma} error on 5.8mag """
b4mag = models.FloatField(default=0.0,null=True)
""" 8.0um IRAC (Band 1) magnitude """
e_b4mag = models.FloatField(default=0.0,null=True)
""" 1-{sigma} error on 8.0mag """
glon = models.FloatField(default=0.0,null=True)
glat = models.FloatField(default=0.0,null=True)
class Meta:
ordering = ['-id']
def __str__(self):
return "{}".format(self.name)
class TwoMASS(models.Model):
""" 2MASS All-Sky Catalog of Point Sources (Cutri+ 2003) """
healpix = models.BigIntegerField(db_index=True, default=0)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
error_radius = models.FloatField(default=0.5)
""" additional field for cross-match """
name = models.CharField(max_length=17,blank=True, default='')
jmag = models.FloatField(default=0.0,null=True)
e_jmag = models.FloatField(default=0.0,null=True)
hmag = models.FloatField(default=0.0,null=True)
e_hmag = models.FloatField(default=0.0,null=True)
kmag = models.FloatField(default=0.0,null=True)
e_kmag = models.FloatField(default=0.0,null=True)
qkfg = models.CharField(max_length=3,blank=True,null=True,default='')
rkfg = models.CharField(max_length=3,blank=True,null=True,default='')
bkfg = models.CharField(max_length=3,blank=True,null=True,default='')
ckfg = models.CharField(max_length=3,blank=True,null=True,default='')
prox = models.FloatField(default=0.0,null=True)
""" Distance between source and nearest neighbour """
xflg = models.BooleanField(default=False,null=True)
""" (gal_contam) Extended source contamination """
aflg = models.BooleanField(default=False,null=True)
""" (mp_flg) Association with asteroid or comet """
glon = models.FloatField(default=0.0)
glat = models.FloatField(default=0.0)
class Meta:
ordering = ['-id']
def __str__(self):
return "2MASS {}".format(self.name)
#RAJ2000','DEJ2000','2MASS','Jmag','e_Jmag','Hmag','e_Hmag','Kmag','e_Kmag','Qflg','Rflg','Bflg','Cflg','prox','Xflg','Aflg','GLON','GLAT'
class GaiaSourceFile(models.Model):
""" Used for Gaia loading and indexing """
filename = models.CharField(max_length=80,blank=True, default='')
status = models.CharField(max_length=7, default='empty') # 00 empty, 01 loaded, 03 healpix
nrows = models.IntegerField(default=0)
""" Number of sources in file """
class GAIADR2(models.Model):
""" Gaia DR2 Catalog
See detailed description of Gaia DR2 data model_.
.. _model: https://gea.esac.esa.int/archive/documentation/GDR2/Gaia_archive/chap_datamodel/sec_dm_main_tables/ssec_dm_gaia_source.html
"""
filename = models.ForeignKey(GaiaSourceFile, on_delete=models.CASCADE)
healpix = models.BigIntegerField(db_index=True, default=0)
""" HEALPIX source index """
solution_id = models.CharField(max_length=19, blank=True, default='')
""" Solution Identifier (long)
All Gaia data processed by the Data Processing and Analysis Consortium
comes tagged with a solution identifier. This is a numeric field attached
to each table row that can be used to unequivocally identify the version
of all the subsystems that where used in the generation of the data
as well as the input data used. It is mainly for internal DPAC use but
is included in the published data releases to enable end users to examine
the provenance of processed data products. To decode a given solution ID
visit https://gaia.esac.esa.int/decoder/solnDecoder.jsp
"""
name = models.CharField(max_length=30,blank=True, default='')
""" Unique source designation (unique across all Data Releases) (string) """
source_id = models.CharField(max_length=19,blank=True, default='')
""" Unique source identifier (unique within a particular Data Release) (long)
A unique numerical identifier of the source, encoding the approximate
position of the source (roughly to the nearest arcmin), the provenance
(data processing centre where it was created), a running number,
and a component number.
"""
error_radius = models.FloatField(default=0.0)
""" additional field for cross-match """
ref_epoch = models.FloatField(default=0.0)
""" Reference epoch (double, Time[Julian Years]) """
ra = models.FloatField(default=0.0)
""" Right ascension (double, Angle[deg])
Barycentric right ascension of the source in ICRS at the reference epoch ref_epoch
"""
ra_error = models.FloatField(default=0.0)
""" Standard error of right ascension (double, Angle[mas]) """
dec = models.FloatField(default=0.0)
""" Declination (double, Angle[deg])
Barycentric declination of the source in ICRS at the reference epoch ref_epoch
"""
dec_error = models.FloatField(default=0.0)
""" Standard error of declination (double, Angle[mas]) """
parallax = models.FloatField(default=0.0)
""" Parallax (double, Angle[mas])
Absolute stellar parallax ϖ of the source at the reference epoch ref_epoch
"""
parallax_error = models.FloatField(default=0.0)
""" Standard error of parallax (double, Angle[mas])
Standard error of the stellar parallax at the reference epoch ref_epoch
"""
pmra = models.FloatField(default=0.0)
""" Proper motion in right ascension direction (double, Angular Velocity[mas/year]) """
pmra_error = models.FloatField(default=0.0)
""" Standard error of proper motion in right ascension direction (double, Angular Velocity[mas/year]) """
pmdec = models.FloatField(default=0.0)
""" Proper motion in declination direction (double, Angular Velocity[mas/year]) """
pmdec_error = models.FloatField(default=0.0)
""" Standard error of proper motion in declination direction (double, Angular Velocity[mas/year]) """
phot_g_mean_mag = models.FloatField(default=0.0)
""" G-band mean magnitude (float, Magnitude[mag])
Mean magnitude in the G band. This is computed from the G-band mean
flux applying the magnitude zero-point in the Vega scale.
"""
phot_bp_mean_mag = models.FloatField(default=0.0)
""" Integrated BP mean magnitude (float, Magnitude[mag])
Mean magnitude in the integrated BP band. This is computed
from the BP-band mean flux applying the magnitude zero-point in the Vega scale.
"""
phot_rp_mean_mag = models.FloatField(default=0.0)
""" Integrated RP mean magnitude (float, Magnitude[mag])
Mean magnitude in the integrated RP band. This is computed from the
RP-band mean flux applying the magnitude zero-point in the Vega scale.
"""
# http://vizier.u-strasbg.fr/viz-bin/VizieR-S?Gaia%20DR2%20431160672954647552
def get_absolute_url_vizier(self):
return "http://vizier.u-strasbg.fr/viz-bin/VizieR-S?" + urllib.parse.quote_plus(self.name)
def get_absolute_url(self):
return "/astrobasis/%i/gaia" % (self.pk)
class GaiaSourceFileDR3(models.Model):
""" Used for Gaia loading and indexing """
filename = models.CharField(max_length=80,blank=True, default='')
status = models.CharField(max_length=7, default='empty') # 00 empty, 01 loaded, 03 healpix
nrows = models.IntegerField(default=0)
""" Number of sources in file """
class GAIADR3(models.Model):
""" Gaia DR3 Catalog """
filename = models.ForeignKey(GaiaSourceFileDR3, on_delete=models.CASCADE)
healpix = models.BigIntegerField(db_index=True, default=0)
""" HEALPIX source index """
#solution_id = models.CharField(max_length=19, blank=True, default='')
""" Solution Identifier (long)
All Gaia data processed by the Data Processing and Analysis Consortium
comes tagged with a solution identifier. This is a numeric field attached
to each table row that can be used to unequivocally identify the version
of all the subsystems that where used in the generation of the data
as well as the input data used. It is mainly for internal DPAC use but
is included in the published data releases to enable end users to examine
the provenance of processed data products. To decode a given solution ID
visit https://gaia.esac.esa.int/decoder/solnDecoder.jsp
"""
name = models.CharField(max_length=30,blank=True, default='')
""" Unique source designation (unique across all Data Releases) (string) """
source_id = models.CharField(max_length=19,blank=True, default='')
""" Unique source identifier (unique within a particular Data Release) (long)
A unique numerical identifier of the source, encoding the approximate
position of the source (roughly to the nearest arcmin), the provenance
(data processing centre where it was created), a running number,
and a component number.
"""
error_radius = models.FloatField(default=0.0)
""" additional field for cross-match """
#ref_epoch = models.FloatField(default=0.0)
""" Reference epoch (double, Time[Julian Years]) """
ra = models.FloatField(default=0.0)
""" Right ascension (double, Angle[deg])
Barycentric right ascension of the source in ICRS at the reference epoch ref_epoch
"""
ra_error = models.FloatField(default=0.0)
""" Standard error of right ascension (double, Angle[mas]) """
dec = models.FloatField(default=0.0)
""" Declination (double, Angle[deg])
Barycentric declination of the source in ICRS at the reference epoch ref_epoch
"""
dec_error = models.FloatField(default=0.0)
""" Standard error of declination (double, Angle[mas]) """
parallax = models.FloatField(default=0.0)
""" Parallax (double, Angle[mas])
Absolute stellar parallax ϖ of the source at the reference epoch ref_epoch
"""
parallax_error = models.FloatField(default=0.0)
""" Standard error of parallax (double, Angle[mas])
Standard error of the stellar parallax at the reference epoch ref_epoch
"""
pmra = models.FloatField(default=0.0)
""" Proper motion in right ascension direction (double, Angular Velocity[mas/year]) """
pmra_error = models.FloatField(default=0.0)
""" Standard error of proper motion in right ascension direction (double, Angular Velocity[mas/year]) """
pmdec = models.FloatField(default=0.0)
""" Proper motion in declination direction (double, Angular Velocity[mas/year]) """
pmdec_error = models.FloatField(default=0.0)
""" Standard error of proper motion in declination direction (double, Angular Velocity[mas/year]) """
phot_g_mean_mag = models.FloatField(default=0.0)
""" G-band mean magnitude (float, Magnitude[mag])
Mean magnitude in the G band. This is computed from the G-band mean
flux applying the magnitude zero-point in the Vega scale.
"""
phot_bp_mean_mag = models.FloatField(default=0.0)
""" Integrated BP mean magnitude (float, Magnitude[mag])
Mean magnitude in the integrated BP band. This is computed
from the BP-band mean flux applying the magnitude zero-point in the Vega scale.
"""
phot_rp_mean_mag = models.FloatField(default=0.0)
""" Integrated RP mean magnitude (float, Magnitude[mag])
Mean magnitude in the integrated RP band. This is computed from the
RP-band mean flux applying the magnitude zero-point in the Vega scale.
"""
# http://vizier.u-strasbg.fr/viz-bin/VizieR-S?Gaia%20DR2%20431160672954647552
def get_absolute_url_vizier(self):
return "http://vizier.u-strasbg.fr/viz-bin/VizieR-S?" + urllib.parse.quote_plus(self.name)
def get_absolute_url(self):
return "/astrobasis/%i/gaiadr3" % (self.pk)
def __str__(self):
return "{}".format(self.name)
def ztf_filter(x):
return {
1: 'g',
2: 'r',
3: 'i',
}[x]
class ZTFAlert(models.Model):
""" ZTF Alert
See detailed description of ZTF data ztf-model_.
.. _ztf-model: https://zwickytransientfacility.github.io/ztf-avro-alert/schema.html
"""
survey = models.ManyToManyField('monthplan.Survey')
""" Reference to Survey """
objectId = models.CharField(max_length=12, blank=True, default='')
fid = models.IntegerField(db_index=True, default=0)
""" Filter ID (1=g; 2=r; 3=i) """
lco_id = models.BigIntegerField(db_index=True, default=0)
""" unique identifier for this object """
healpix = models.BigIntegerField(db_index=True, default=0)
""" HEALPIX source index """
healpix_plate = models.IntegerField(default=0)
""" HEALPIX plate index """
ra = models.FloatField(default=0.0)
""" Right ascension (double, Angle[deg]) """
dec = models.FloatField(default=0.0)
""" Declination (double, Angle[deg]) """
programid = models.IntegerField(db_index=True, default=0)
""" Program ID: encodes either public, collab, or caltech mode """
magpsf = models.FloatField(default=0.0)
""" magnitude from PSF-fit photometry [mag] """
sigmapsf = models.FloatField(default=0.0)
""" 1-sigma uncertainty in magpsf [mag] """
fwhm = models.FloatField(default=0.0)
""" Full Width Half Max assuming a Gaussian core, from SExtractor [pixels] """
elong = models.FloatField(default=0.0)
""" Ratio: aimage / bimage """
magap = models.FloatField(default=0.0)
""" Aperture mag using 8 pixel diameter aperture [mag] """
magdiff = models.FloatField(default=0.0)
""" Difference: magap - magpsf [mag] """
nbad = models.IntegerField(default=0)
""" number of prior-tagged bad pixels in a 5 x 5 pixel stamp """
sigmagap = models.FloatField(default=0.0)
""" 1-sigma uncertainty in magap [mag] """
#wall_time = models.CharField(max_length=29, blank=True, default='')
wall_time = models.DateTimeField(default=datetime.now, blank=True)
diffmaglim = models.FloatField(default=0.0)
""" 5-sigma mag limit in difference image based on PSF-fit photometry [mag] """
deltamagref = models.FloatField(default=0.0,null=True)
deltamaglatest = models.FloatField(default=0.0,null=True)
rb = models.FloatField(default=0.0)
""" RealBogus quality score; range is 0 to 1 where closer to 1 is more reliable """
created = models.DateTimeField(auto_now_add=True)
""" Date and time of creation. Fully automatic. """
def get_alerce_url(self):
return "https://alerce.online/object/%s" % (self.objectId)
def get_mars_url(self):
return "https://mars.lco.global/%i/" % (self.lco_id)
def get_filter(self):
return "%s" % (ztf_filter(self.fid))
def __str__(self):
return "%s" % (self.objectId)
def alerce_early_class(x):
return {
18: 'AGN',
19: 'SN',
20: 'VS',
21: 'Astrd',
22: 'Bogus',
}[x]
def alerce_late_class(x):
return 'N/A'
class ALeRCE(models.Model):
""" ALeRCE ZTF Alerts
See detailed description of ZTF data alerce-model_.
.. _alerce-model: https://zwickytransientfacility.github.io/ztf-avro-alert/schema.html
"""
survey = models.ManyToManyField('monthplan.Survey')
""" Reference to Survey """
healpix = models.BigIntegerField(db_index=True, default=0)
""" HEALPIX source index """
healpix_plate = models.IntegerField(default=0)
""" HEALPIX plate index """
created = models.DateTimeField(auto_now_add=True)
""" Date and time of creation. Fully automatic. """
classearly = models.IntegerField(default=0, null=True)
""" Early Classifier (Stamp Classifier) """
error_radius = models.FloatField(default=0.0)
""" additional field for cross-match """
classrf = models.IntegerField(default=0, null=True)
""" Late Classifier (Random Forest) """
firstdate = models.DateTimeField(default=datetime.now)
lastdate = models.DateTimeField(default=datetime.now)
oid = models.CharField(max_length=12, default='')
firstmjd = models.FloatField(default=0.0)
lastmjd = models.FloatField(default=0.0)
mean_magap_g = models.FloatField(default=0.0, null=True)
mean_magap_r = models.FloatField(default=0.0, null=True)
mean_magpsf_g = models.FloatField(default=0.0, null=True)
mean_magpsf_r = models.FloatField(default=0.0, null=True)
dec = models.FloatField(default=0.0)
ra = models.FloatField(default=0.0)
nobs = models.IntegerField(default=0)
pclassearly = models.FloatField(default=0.0, null=True)
pclassrf = models.FloatField(default=0.0, null=True)
sigma_magap_g = models.FloatField(default=0.0, null=True)
sigma_magap_r = models.FloatField(default=0.0, null=True)
sigma_magpsf_g = models.FloatField(default=0.0, null=True)
sigma_magpsf_r = models.FloatField(default=0.0, null=True)
sigmadec = models.FloatField(default=0.0, null=True)
sigmara = models.FloatField(default=0.0, null=True)
def get_absolute_url(self):
return "/astrobasis/%i/alerce" % (self.pk)
def get_alerce_url(self):
return "https://alerce.online/object/%s" % (self.oid)
def get_tns_url(self):
return "https://wis-tns.weizmann.ac.il/object/%s" % (self.oid)
def __str__(self):
return "ALeRCE %s" % (self.oid)
def get_early_class(self):
if(self.classearly):
return "%s" % (alerce_early_class(self.classearly))
else:
return None
class SDSSDR12Spec(models.Model):
""" SDSS DR 12 Spectra """
healpix = models.BigIntegerField(db_index=True, default=0)
""" HEALPIX source index """
MJD = models.FloatField(default=0.0)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
obj_class = models.CharField(max_length=6, default='')
obj_subclass = models.CharField(max_length=21, default='')
z = models.FloatField(default=0.0)
z_err = models.FloatField(default=0.0)
specobjid = models.CharField(max_length=22, default='')
targetobjid = models.CharField(max_length=22, default='')
class Flesch(models.Model):
""" Flesch 2019 catalog VII/283 """
healpix = models.BigIntegerField(db_index=True, default=0)
""" HEALPIX source index """
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
name = models.CharField(max_length=25, default="")
obj_class = models.CharField(max_length=4, default='')
Rmag = models.FloatField(default=0.0)
Bmag = models.FloatField(default=0.0)
z = models.FloatField(default=0.0)
class Simbad(models.Model):
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
main_id = models.CharField(max_length=51, unique=True)
obj_class = models.CharField(max_length=30, default='')
coo_bibcode = models.CharField(max_length=25, default="")
coo_wavelength = models.CharField(max_length=5, default="")
z = models.FloatField(default=0.0)
otype = models.CharField(max_length=21, default="")
def is_redshift_real(self):
return isfinite(self.z)
def is_error_radius_real(self):
return isfinite(self.error_radius)
def __str__(self):
return "{}:{}/{}".format(self.main_id,self.obj_class,self.otype)
class AllWise(models.Model):
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=51, unique=True)
W1mag = models.FloatField(default=0.0)
e_W1mag = models.FloatField(default=0.0)
W2mag = models.FloatField(default=0.0)
e_W2mag = models.FloatField(default=0.0)
def __str__(self):
return "{}".format(self.name)
def w1w2(self):
if self.W1mag and self.W2mag:
return self.W1mag-self.W2mag
else:
return None
def w1w2_error(self):
if self.e_W1mag and self.e_W2mag:
return sqrt(self.e_W1mag*self.e_W1mag + self.e_W2mag*self.e_W2mag)
else:
return None
def get_vizier_url(self):
return "https://vizier.u-strasbg.fr/viz-bin/VizieR-5?-source=II/328/allwise&AllWISE==="+urllib.parse.quote(self.name)
def get_irsa_url(self):
return "http://irsa.ipac.caltech.edu/applications/wise/#id=Hydra_wise_wise_1&DoSearch=true&schema=allwise-multiband&intersect=CENTER&subsize=0.20&mcenter=mcen&band=1,2,3,4&dpLevel=3a&UserTargetWorldPt={};{};EQ_J2000&SimpleTargetPanel.field.resolvedBy=simbadthenned&coaddId=&projectId=wise&searchName=wise_1&startIdx=0&pageSize=0&shortDesc=Position&isBookmarkAble=true&isDrillDownRoot=true&isSearchResult=true".format(self.ra,self.dec)
class NVSS(models.Model):
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
e_ra = models.FloatField(default=0.0)
e_dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=51, unique=True)
S14 = models.FloatField(default=0.0)
e_S14 = models.FloatField(default=0.0)
def __str__(self):
return "{}".format(self.name)
def get_vizier_url(self):
return "https://vizier.u-strasbg.fr/viz-bin/VizieR-5?-source=VIII/65/nvss&NVSS=="+urllib.parse.quote(self.name)
class FIRST(models.Model):
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=51, unique=True)
Fpeak = models.FloatField(default=0.0)
Fint = models.FloatField(default=0.0)
rms = models.FloatField(default=0.0)
major_axis = models.FloatField(default=0.0)
minor_axis = models.FloatField(default=0.0)
def __str__(self):
return "{}".format(self.name)
def get_vizier_url(self):
return "https://vizier.u-strasbg.fr/viz-bin/VizieR-5?-source=VIII/92/first14&FIRST=="+urllib.parse.quote(self.name)
class Meta:
ordering = ['-id']
class SUMSS(models.Model):
ra_orig = models.CharField(max_length=51, unique=False)# models.FloatField(default=0.0)
dec_orig = models.CharField(max_length=51, unique=False) # models.FloatField(default=0.0)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
e_ra = models.FloatField(default=0.0)
e_dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=51, unique=True)
Sp = models.FloatField(default=0.0)
e_Sp = models.FloatField(default=0.0)
St = models.FloatField(default=0.0)
e_St = models.FloatField(default=0.0)
major_axis = models.FloatField(default=0.0)
minor_axis = models.FloatField(default=0.0)
def __str__(self):
return "{}".format(self.name)
def get_vizier_url(self):
return "https://vizier.u-strasbg.fr/viz-bin/VizieR-5?-source=VIII/81B/sumss212&RAJ2000=="+urllib.parse.quote(self.ra_orig)
class Meta:
ordering = ['-id']
class VLASS(models.Model):
glon = models.FloatField(default=0.0)
glat = models.FloatField(default=0.0)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
e_ra = models.FloatField(default=0.0)
""" 1-sigma uncertainty in RA """
e_dec = models.FloatField(default=0.0)
""" 1-sigma uncertainty in DEC """
ra_m = models.FloatField(default=0.0)
""" Right Ascension (J2000) of the component peak brightness (RA_max) """
dec_m = models.FloatField(default=0.0)
""" Declination (J2000) of the component peak brightness (DEC_max) """
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=31, unique=False)
""" CompName (A31) IAU name of the component, VLASS1QLCIR JHHMMSS.ss+DDMMSS.s """
ftot = models.FloatField(default=0.0)
""" The integrated flux density of the component in the S-band (2-4GHz) """
e_ftot = models.FloatField(default=0.0)
""" 1-sigma uncertainty in total flux """
fpeak = models.FloatField(default=0.0)
""" Peak brightness of the component in the S-band (2-4GHz) """
e_fpeak = models.FloatField(default=0.0)
""" 1-sigma uncertainty in peak flux """
dupflag = models.IntegerField(default=0)
""" DupFlag (I1) [0/2] Flag to identify duplicate detections (Duplicate) """
qualflag = models.IntegerField(default=0)
""" QualFlag (I1) [0/7] Flag to denote the Quality of the detection """
def __str__(self):
return "{}".format(self.name)
def get_vizier_url(self):
return "https://vizier.u-strasbg.fr/viz-bin/VizieR-5?-source=VIII/81B/sumss212&RAJ2000=="+urllib.parse.quote(self.ra_orig)
class Meta:
ordering = ['-id']
class VLASSfromVizieR(models.Model):
recno = models.IntegerField(default=0)
glon = models.FloatField(default=0.0)
glat = models.FloatField(default=0.0)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
e_ra = models.FloatField(default=0.0)
""" 1-sigma uncertainty in RA """
e_dec = models.FloatField(default=0.0)
""" 1-sigma uncertainty in DEC """
#ra_m = models.FloatField(default=0.0)
""" Right Ascension (J2000) of the component peak brightness (RA_max) """
#dec_m = models.FloatField(default=0.0)
""" Declination (J2000) of the component peak brightness (DEC_max) """
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=31, unique=False)
""" CompName (A31) IAU name of the component, VLASS1QLCIR JHHMMSS.ss+DDMMSS.s """
ftot = models.FloatField(default=0.0)
""" The integrated flux density of the component in the S-band (2-4GHz) """
e_ftot = models.FloatField(default=0.0)
""" 1-sigma uncertainty in total flux """
fpeak = models.FloatField(default=0.0)
""" Peak brightness of the component in the S-band (2-4GHz) """
e_fpeak = models.FloatField(default=0.0)
""" 1-sigma uncertainty in peak flux """
dupflag = models.IntegerField(default=0)
""" DupFlag (I1) [0/2] Flag to identify duplicate detections (Duplicate) """
qualflag = models.IntegerField(default=0)
""" QualFlag (I1) [0/7] Flag to denote the Quality of the detection """
def __str__(self):
return "{}".format(self.name)
def get_vizier_url(self):
return "https://vizier.cds.unistra.fr/viz-bin/VizieR-5?-source=J/ApJS/255/30/comp&recno={}".format(self.recno)
class Meta:
ordering = ['-id']
class BJfromVizieR(models.Model):
#recno = models.IntegerField(default=0)
#glon = models.FloatField(default=0.0)
#glat = models.FloatField(default=0.0)
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
r_med_geo = models.FloatField(default=0.0)
r_lo_geo = models.FloatField(default=0.0)
r_hi_geo = models.FloatField(default=0.0)
r_med_pgeo = models.FloatField(default=0.0)
r_lo_pgeo = models.FloatField(default=0.0)
r_hi_pgeo = models.FloatField(default=0.0)
#flag = models.CharField(max_length=6, unique=False)
source_id = models.BigIntegerField(db_index=True, default=0)
#source_id = models.CharField(max_length=19,blank=True, default='')
#Unique source identifier (unique within a particular Data Release) (long)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.00035) # arXiv:2202.08369v1
def __str__(self):
return "{}".format(self.source_id)
def get_vizier_url(self):
return "http://vizier.cds.unistra.fr/viz-bin/VizieR-6?-out.form=%2bH%2bm&-source=I/350/gaia%2a&Source=%20{}".format(self.source_id)
class Meta:
ordering = ['-id']
class GAIADR3fromVizieR(models.Model):
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.00035) # arXiv:2202.08369v1
source_id = models.BigIntegerField(db_index=True, default=0)
e_ra = models.FloatField(default=0.0)
e_dec = models.FloatField(default=0.0)
plx = models.FloatField(default=0.0)
e_plx = models.FloatField(default=0.0)
rplx = models.FloatField(default=0.0)
pm = models.FloatField(default=0.0)
pmra = models.FloatField(default=0.0)
e_pmra = models.FloatField(default=0.0)
pmde = models.FloatField(default=0.0)
e_pmde = models.FloatField(default=0.0)
gmag = models.FloatField(default=0.0)
e_gmag = models.FloatField(default=0.0)
bpmag = models.FloatField(default=0.0)
e_bpmag = models.FloatField(default=0.0)
rpmag = models.FloatField(default=0.0)
e_rpmag = models.FloatField(default=0.0)
def __str__(self):
return "{}".format(self.source_id)
def get_vizier_url(self):
return "https://vizier.cds.unistra.fr"
class Meta:
ordering = ['-id']
class Magnitude(models.Model):
U='U'
B='B'
V='V'
R='R'
I='I'
Z='Z'
Y='Y'
J='J'
H='H'
K='K'
Ks='Ks'
Br_gamma='Br_gamma'
u='u'
g='g'
r='r'
i='i'
z='z'
y='y'
G='G'
Gbr='Gbr'
Grp='Grp'
I1='I1'
I2='I2'
I3='I3'
I4='I4'
MIPS24mu='MIPS.24mu'
MIPS70mu='MIPS.70mu'
MIPS160mu='MIPS.160mu'
W1='W1'
W2='W2'
W3='W3'
W4='W4'
Halpha='Halpha'
SELECTION = [
(U,'U'),
(B,'B'),
(V,'V'),
(R,'R'),
(I,'I'),
(Z,'Z'),
(Y,'Y'),
(J,'J'),
(H,'H'),
(K,'K'),
(Ks,'Ks'),
(Br_gamma,'Br_gamma'),
(u,'u'),
(g,'g'),
(r,'r'),
(Halpha,'Halpha'),
(i,'i'),
(z,'z'),
(y,'y'),
(G,'G'),
(Gbr,'Gbr'),
(Grp,'Grp'),
(I1,'I1'),
(I2,'I2'),
(I3,'I3'),
(I4,'I4'),
(MIPS24mu,'MIPS.24mu'),
(MIPS70mu,'MIPS.70mu'),
(MIPS160mu,'MIPS.160mu'),
(W1,'W1'),
(W2,'W2'),
(W3,'W3'),
(W4,'W4'),
]
magn = models.FloatField(default=0.0)
error = models.FloatField(default=0.0)
band = models.CharField(max_length=10,choices=SELECTION,default=W1,)
class Meta:
verbose_name_plural = "Magnitudes"
def __str__(self):
return "{} {}".format(self.magn, self.band)
def get_delete_url(self):
return "/astrobasis/{}/delmagn".format(self.pk)
class MagnitudeForm(forms.ModelForm):
class Meta:
model = Magnitude
fields = ('band','magn','error')
class AstroBasisUserCat(models.Model):
ra = models.FloatField(default=0.0)
dec = models.FloatField(default=0.0)
healpix = models.BigIntegerField(db_index=True, default=0)
error_radius = models.FloatField(default=0.0)
name = models.CharField(max_length=51, unique=True)
notes = models.TextField("notes",max_length=2000, null=True, blank=True)
bibcode = models.CharField(max_length=36,blank=True, default='')
autoname = models.BooleanField(default=False, null=False, help_text="Generate IAU name of the component in the form <b>NAME JHHMMSS.s+DDMMSS</b>, <br>where NAME is taken from the corresponding field above.")
magnitudes = models.ManyToManyField('Magnitude')
def __str__(self):
return "{}".format(self.name)
class Meta:
ordering = ['-id']
def get_update_url(self):
return "/astrobasis/%i/usercat/update" % (self.pk)
def get_delete_url(self):
return "/astrobasis/%i/usercat/delete" % (self.pk)
def get_add_magn_url(self):
return "/astrobasis/%i/usercat/addmagn" % (self.pk)
class AstroBasisUserCatForm(forms.ModelForm):
class Meta:
model = AstroBasisUserCat
fields = ('name','autoname','ra', 'dec', 'error_radius','bibcode','notes')