65 lines
1.9 KiB
Python
65 lines
1.9 KiB
Python
from django.core.management.base import BaseCommand, CommandError
|
|
|
|
from datetime import date
|
|
from heasarc.models import INPUT_DATA_DIR
|
|
import datetime
|
|
from django.utils import timezone
|
|
import astropy
|
|
from astropy.io import ascii
|
|
import pandas as pd
|
|
import pymysql
|
|
from sqlalchemy import create_engine
|
|
import numpy.ma as ma
|
|
from heasarc.tdat import tDat
|
|
from heasarc.models import HeasarcTable, TableColumn, HeasarcRASS2RXS, HeasarcObjectClass
|
|
from heasarc.models import NSIDE_SOURCES, ORDER
|
|
from monthplan.models import NSIDE_PLATES
|
|
|
|
from astropy_healpix import HEALPix
|
|
from astropy.coordinates import SkyCoord # High-level coordinates
|
|
from astropy.coordinates import ICRS, Galactic, FK4, FK5 # Low-level frames
|
|
from astropy.coordinates import Angle, Latitude, Longitude # Angles
|
|
import astropy.units as u
|
|
import math
|
|
|
|
def update_heasarc_table():
|
|
|
|
srcs = HeasarcRASS2RXS.objects.all()
|
|
"""
|
|
for src in srcs:
|
|
dx=src.x_pixel_error
|
|
dy=src.y_pixel_error
|
|
error_radius=math.sqrt(dx*dx+dy*dy)*45*1.42
|
|
print("{} {}".format(error_radius,src.error_radius))
|
|
"""
|
|
|
|
objs = []
|
|
pixsize=45 # arcseconds
|
|
for src in srcs:
|
|
dx=src.x_pixel_error
|
|
dy=src.y_pixel_error
|
|
#src.error_radius = math.sqrt(dx*dx+dy*dy)*pixsize*1.42
|
|
|
|
P=0.98
|
|
src.error_radius = max(dx,dy)*pixsize*math.sqrt(-2*math.log(1-P))
|
|
|
|
objs.append(src)
|
|
HeasarcRASS2RXS.objects.bulk_update(objs, ['error_radius'], batch_size=1000)
|
|
"""
|
|
The X image coordinate of the source from the local sliding cell detection on an X-ray image of 512 by 512 pixels
|
|
with 45 arcsecond square pixels.
|
|
|
|
The 1-sigma error in the X image coordinate of the source.
|
|
|
|
R(P)_2D = Sigma_1D * sqrt (-2 * ln(1-P))
|
|
|
|
"""
|
|
class Command(BaseCommand):
|
|
help = 'Initiates data dase'
|
|
|
|
def handle(self, *args, **options):
|
|
|
|
update_heasarc_table()
|
|
|
|
self.stdout.write(self.style.SUCCESS('Done'))
|