示例#1
0
def add_transient(obj):
    import os
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'torosweb.settings')
    import django
    django.setup()
    from winnow.models import TransientCandidate

    t = TransientCandidate()
    t.ra         = obj['ra']
    t.dec        = obj['dec']
    t.x_pix      = obj['x']
    t.y_pix      = obj['y']
    t.height     = obj['ymax'] - obj['ymin']
    t.width      = obj['xmax'] - obj['xmin']
    t.filename   = obj['filename']
    t.dataset_id = obj['dataset']
    try:
      lastTC = TransientCandidate.objects.filter(dataset_id=dataset).order_by('-object_id')[0]
      last_id = lastTC.object_id
    except IndexError:
      last_id = 0
    t.object_id = last_id + 1
    t.save()
    t.refImg  = 'object_images/%s_ref.png' % (t.slug)
    t.subtImg = 'object_images/%s_subt.png' % (t.slug)
    t.origImg = 'object_images/%s_orig.png' % (t.slug)
    t.save()

    return t
示例#2
0
def add_transient(xy, radec):
    t = TransientCandidate()
    t.ra         = radec[0]
    t.dec        = radec[1]
    t.x_pix      = xy[0]
    t.y_pix      = xy[1]
    t.width      = 10
    t.height     = 10
    t.filename   = "testFile.fits"
    t.dataset_id = "DBG_DJANGO"
    try:
      lastTC = TransientCandidate.objects.filter(dataset_id="DBG_DJANGO").order_by('-object_id')[0]
      last_id = lastTC.object_id
    except IndexError:
      last_id = 0
    t.object_id = last_id + 1
    t.save()
    t.refImg  = 'object_images/%s_ref.png' % (t.slug)
    t.subtImg = 'object_images/%s_subt.png' % (t.slug)
    t.origImg = 'object_images/%s_orig.png' % (t.slug)
    t.save()
    
    #Make all plots for this object
    thumb(xy[0], xy[1], t.filename, t.slug)
    return t
示例#3
0
def add_transient(obj):
    import os
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'torosweb.settings')
    import django
    django.setup()
    from winnow.models import TransientCandidate, Dataset

    try:
        ds = Dataset.objects.get(name=obj['dataset'])
    except:
        ds = Dataset()
        ds.name = obj['dataset']
        ds.isCurrent = True
        ds.save()

    t = TransientCandidate()
    t.ra = obj['ra']
    t.dec = obj['dec']
    t.x_pix = obj['x']
    t.y_pix = obj['y']
    t.height = obj['ymax'] - obj['ymin']
    t.width = obj['xmax'] - obj['xmin']
    t.filename = obj['filename']
    t.dataset = ds
    t.object_id = obj['object_id']
    t.save()
    t.refImg = 'object_images/%s_ref.png' % (t.slug)
    t.subtImg = 'object_images/%s_subt.png' % (t.slug)
    t.origImg = 'object_images/%s_orig.png' % (t.slug)
    t.save()

    return t
示例#4
0
def add_transient(obj):
    import os
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'torosweb.settings')
    import django
    django.setup()
    from winnow.models import TransientCandidate, Dataset

    try:
        ds = Dataset.objects.get(name=obj['dataset'])
    except:
        ds = Dataset()
        ds.name = obj['dataset']
        ds.isCurrent = True
        ds.save()

    t = TransientCandidate()
    t.ra         = obj['ra']
    t.dec        = obj['dec']
    t.x_pix      = obj['x']
    t.y_pix      = obj['y']
    t.height     = obj['ymax'] - obj['ymin']
    t.width      = obj['xmax'] - obj['xmin']
    t.filename   = obj['filename']
    t.dataset = ds
    t.object_id = obj['object_id']
    t.save()
    t.refImg  = 'object_images/%s_ref.png' % (t.slug)
    t.subtImg = 'object_images/%s_subt.png' % (t.slug)
    t.origImg = 'object_images/%s_orig.png' % (t.slug)
    t.save()

    return t
示例#5
0
def add_transient(xy, radec, fits_filename, dataset, hw_box):
    import os
    os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'torosweb.settings')
    import django
    django.setup()
    from winnow.models import TransientCandidate

    t = TransientCandidate()
    t.ra         = radec[0]
    t.dec        = radec[1]
    t.x_pix      = xy[0]
    t.y_pix      = xy[1]
    t.height     = hw_box['height']
    t.width      = hw_box['width']
    t.filename   = fits_filename
    t.dataset_id = dataset
    try:
      lastTC = TransientCandidate.objects.filter(dataset_id=dataset).order_by('-object_id')[0]
      last_id = lastTC.object_id
    except IndexError:
      last_id = 0
    t.object_id = last_id + 1
    t.save()
    t.refImg  = 'object_images/%s_ref.png' % (t.slug)
    t.subtImg = 'object_images/%s_subt.png' % (t.slug)
    t.origImg = 'object_images/%s_orig.png' % (t.slug)
    t.save()

    return t