コード例 #1
0
ファイル: views.py プロジェクト: rovor/RedROVOR
def fieldObjectAdd(request):
    '''add a field object to the database'''
    FOForm = modelform_factory(FieldObject,fields=['target','ra','dec','isTarget'])
    form = FOForm(request.POST)
    if form.is_valid():
        obj = form.save()
        return okJSONResponse({'id':obj.id, 'ra':str(obj.ra),'dec':str(obj.dec), 'isTarget':obj.isTarget})
    else:
        return errorJSONResponse(form.errors)
コード例 #2
0
ファイル: views.py プロジェクト: rovor/RedROVOR
def fieldObjectAddTarget(request):
    '''add the target object to the list of coordinates for that target'''
    try:
        targ = Target.objects.get(pk=request.POST['target'])
        fobj = FieldObject(target=targ, ra=targ.ra, dec=targ.dec,isTarget=True)
        fobj.save() 
        return okJSONResponse(FieldObject2dict(fobj))
    except Exception as e:
        logger.debug(e)
        return errorJSONResponse("targetID must be supplied and a valid target")
コード例 #3
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def subZeroDark(path):
    '''subtract zeros and darks from the object files in a folder'''
    try:
        improc = FirstPassProcessor(path)
        logger.info("Processing object files in " + path)
        improc.zero_and_dark_subtract()
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc())  #log the traceback
        raise e
コード例 #4
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def makeFlats(path):
    '''make master flats from a folder'''
    try:
        improc = FirstPassProcessor(path)
        logger.info("Making flats at path " + path)
        improc.makeFlats()
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc())  #log the traceback
        raise e
コード例 #5
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def subZeroDark(path):
    '''subtract zeros and darks from the object files in a folder'''
    try:
        improc = FirstPassProcessor(path)
        logger.info("Processing object files in "+path)
        improc.zero_and_dark_subtract()
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc()) #log the traceback
        raise e
コード例 #6
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def makeFlats(path):
    '''make master flats from a folder'''
    try:
        improc = FirstPassProcessor(path)
        logger.info("Making flats at path " + path)
        improc.makeFlats()
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc()) #log the traceback
        raise e
コード例 #7
0
ファイル: views.py プロジェクト: rovor/RedROVOR
def uploadCoordFile(request,targetID):
    '''upload a coordinate file for a target'''
    try:
        f = request.FILES['coords']
        result = []
        with transaction.commit_on_success():
            for ra,dec in parseCoords(f):
                logger.info("Adding object at {0} {1}".format(ra,dec))
                obj = FieldObject(target_id=targetID,ra=ra,dec=dec,isTarget=False)
                obj.save()
                result.append(FieldObject2dict(obj))
        return okJSONResponse(result)
    except Exception as ex:
        return errorJSONResponse(str(ex))
コード例 #8
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def firstPass(path):
    '''perform the first pass over the folder
    i.e. create calibration frames and apply zeros 
    and darks to the object frames, and save them in the processed folder
    '''
    try:
        doFirstPass(path)
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc())  #log the traceback
        raise e
コード例 #9
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def firstPass(path):
    '''perform the first pass over the folder
    i.e. create calibration frames and apply zeros 
    and darks to the object frames, and save them in the processed folder
    '''
    try:
        doFirstPass(path)
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc()) #log the traceback
        raise e
コード例 #10
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def applyFlats(request,path):
    '''apply the given flats to the supplied path'''
    try:
        flats = json.loads(request.POST['flats'])
        for filt,flat in flats.items():
            flats[filt] = Filesystem.getTruePath(flat)
        improc = SecondPassProcessor(path)
        improc.applyFlats(flats)
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc()) #log the traceback
        raise e
コード例 #11
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def applyFlats(request, path):
    '''apply the given flats to the supplied path'''
    try:
        flats = json.loads(request.POST['flats'])
        for filt, flat in flats.items():
            flats[filt] = Filesystem.getTruePath(flat)
        improc = SecondPassProcessor(path)
        improc.applyFlats(flats)
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc())  #log the traceback
        raise e
コード例 #12
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def secondPass(request,path):
    '''perform the second pass over the folder
    i.e. apply flats and apply world coordinate system
    '''
    try:
        if 'flats' not in request.POST:
            return HttpResponseBadRequest("No flats specified")
        flats = json.loads(request.POST['flats'])
        for filt,flat in flats.items():
            flats[filt] = Filesystem.getTruePath(flat)
        doSecondPass(path,flats)
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc()) #log the traceback
        raise e
コード例 #13
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def secondPass(request, path):
    '''perform the second pass over the folder
    i.e. apply flats and apply world coordinate system
    '''
    try:
        if 'flats' not in request.POST:
            return HttpResponseBadRequest("No flats specified")
        flats = json.loads(request.POST['flats'])
        for filt, flat in flats.items():
            flats[filt] = Filesystem.getTruePath(flat)
        doSecondPass(path, flats)
        return okJSONResponse()
    except ValueError as e:
        return errorJSONResponse(str(e))
    except Exception as e:
        #an unexpected exception
        logger.debug(traceback.format_exc())  #log the traceback
        raise e
コード例 #14
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def photSelectFolder(request, path):
    '''Allows a client to select a path for performing,
    photometry. The client must supply the paramater 'path',
    which is the virtual path to the folder to perform photometry in,
    and will receive a Json object which contains an object of the following form
        ok: True if the request succeeded
        error: the error message if ok is false, not present if ok is true
        result: the response if ok is true, not present if ok is false, it will be a list
            of objects that do not have coordinates for them, if all objects have coordinates it will
            be an empty list.
    It is up to the client whether to continue forward or not if there are missing coordinates, the client
    can also use the targets API to upload more coordinates.'''
    try:
        mapping, missing = getObjectMapping(path)
        request.session['phot.object_mapping'] = mapping
        request.session['phot.path'] = path
        return okJSONResponse(missing)
    except Exception as e:
        logger.debug(traceback.format_exc())
        return errorJSONResponse(str(e))
コード例 #15
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def photSelectFolder(request,path):
    '''Allows a client to select a path for performing,
    photometry. The client must supply the paramater 'path',
    which is the virtual path to the folder to perform photometry in,
    and will receive a Json object which contains an object of the following form
        ok: True if the request succeeded
        error: the error message if ok is false, not present if ok is true
        result: the response if ok is true, not present if ok is false, it will be a list
            of objects that do not have coordinates for them, if all objects have coordinates it will
            be an empty list.
    It is up to the client whether to continue forward or not if there are missing coordinates, the client
    can also use the targets API to upload more coordinates.'''
    try:
       mapping, missing = getObjectMapping(path)
       request.session['phot.object_mapping'] = mapping
       request.session['phot.path'] = path
       return okJSONResponse(missing)
    except Exception as e:
        logger.debug(traceback.format_exc())
        return errorJSONResponse(str(e))
コード例 #16
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def thirdPass(request):
    '''web service to perform the photometry'''
    #the mapping object has rather sensitive information in it
    #so we don't want the client to deal with it, so we need to
    #have everything in the session
    path = request.session.get('phot.path')
    mapping = request.session.get('phot.object_mapping')
    if path and mapping:
        #clean up session
        del request.session['phot.path']
        del request.session['phot.object_mapping']
    else:
        return HttpResponseBadRequest("No mapping specified")
    try:
        doThirdPass(path, mapping)
    except Exception as e:
        logger.debug(traceback.format_exc())
        return errorJSONResponse(str(e))
    finally:
        #clean up all the temporary files
        # we need to do this no matter what
        for tempFile, _ in mapping.values():
            os.remove(tempFile)
    return okJSONResponse()
コード例 #17
0
ファイル: action_views.py プロジェクト: rovor/RedROVOR
def thirdPass(request):
    '''web service to perform the photometry'''
    #the mapping object has rather sensitive information in it
    #so we don't want the client to deal with it, so we need to
    #have everything in the session
    path = request.session.get('phot.path')
    mapping = request.session.get('phot.object_mapping')
    if path and mapping:
        #clean up session
        del request.session['phot.path'] 
        del request.session['phot.object_mapping'] 
    else:
        return HttpResponseBadRequest("No mapping specified")
    try:
        doThirdPass(path,mapping)
    except Exception as e:
        logger.debug(traceback.format_exc())
        return errorJSONResponse(str(e))
    finally:
        #clean up all the temporary files
        # we need to do this no matter what
        for tempFile, _ in mapping.values():
            os.remove(tempFile)
    return okJSONResponse()