Esempio n. 1
0
    def createFromSqlResult(proposal_id, result):
        """
        Creates a new Session instance initialized using the request from
        an SQL query.
        """

        c = Conversions()

        epoch = SourceCoordinateEpoch.objects.get(epoch = result['coordinate'])
        sys = SourceCoordinateSystem.objects.get(system = result['coordinate_system'])
        vType = SourceVelocityType.objects.get(type = result['velocity_type'])
        ref = SourceReferenceFrame.objects.get(frame = result['referenceFrame'])
        con = SourceConvention.objects.get(convention = result['convention'])
        
        # Occasionally this string can be something dumb like '?'
        try:
            vRedshift = float(result['velocity_redshift'])
        except:
            vRedshift = None

        source = Source(pst_source_id = result['source_id']
                          # Don't use result's because that's for the
                          # PST, not our GB PHT DB!
                        , proposal_id = proposal_id 
                        , target_name = result['target_name']
                        , ra = c.sexHrs2rad(result['right_ascension'])
                        , ra_range = c.sexHrs2rad(result['right_ascension_range'])
                        , dec = c.sexDeg2rad(result['declination'])
                        , dec_range = c.sexDeg2rad(result['declination_range'])
                        , coordinate_epoch = epoch 
                        , coordinate_system = sys 
                        , velocity_units = vType 
                        , velocity_redshift = vRedshift 
                        , convention = con 
                        , reference_frame = ref 
                        , pst_ra = result['right_ascension']
                        , pst_ra_range = result['right_ascension_range']
                        , pst_dec = result['declination']
                        , pst_dec_range = result['declination_range']
                        )

        source.save()
        return source
Esempio n. 2
0
    def createFromSqlResult(result):
        """
        Creates a new Target instance initialized using the request from
        an SQL query.
        """
 
        c = Conversions()

        target = Target(min_lst = c.sexHrs2rad(result['MINIMUM_LST'])
                      , max_lst = c.sexHrs2rad(result['MAXIMUM_LST'])
                      # TBF: why bother importing?  It is soooo FUBAR!
                      #, elevation_min = result['ELEVATION_MINIMUM']      
                      , pst_max_lst = result['MAXIMUM_LST']
                      , pst_min_lst = result['MINIMUM_LST']
                      , pst_elevation_min = result['ELEVATION_MINIMUM']
                       )
        target.save()
        return target