Example #1
0
def build(filename):
    filehandle = storage.open_vos_or_local(filename, "rb")
    filestr = filehandle.read()
    filehandle.close()

    input_mpc_lines = filestr.split('\n')

    mpc_observations = []
    mag = []
    for line in input_mpc_lines:
        mpc_observation = mpc.Observation.from_string(line)
        if mpc_observation is not None:
            if mpc_observation.mag is not None and mpc_observation.mag > 0:
                mag.append(mpc_observation.mag)

            mpc_observations.append(mpc_observation)

    mpc_observations.sort(key=lambda obs: obs.date.jd)
    orbit = Orbfit(mpc_observations)

    mag = numpy.array(mag)
    print(orbit.residuals)

    print(
        "{:10s} {:7.2f} {:7.2f} {:7.3f} {:7.3f} {:7.3f} {:7.3f} {:7.3f} {:7.3f} {:7.3f}"
        .format(orbit.name, orbit.a, orbit.da, orbit.e, orbit.de, orbit.inc,
                orbit.dinc, orbit.distance, mag.mean(), mag.std()))
Example #2
0
File: ssos.py Project: drusk/MOP
    def parse(self, filename):
        filehandle = storage.open_vos_or_local(filename, "rb")
        filestr = filehandle.read()
        filehandle.close()

        input_mpc_lines = filestr.split('\n')

        mpc_observations = []
        for line in input_mpc_lines:
            mpc_observation = mpc.Observation.from_string(line)
            if mpc_observation is not None:
                mpc_observations.append(mpc_observation)

        mpc_observations.sort(key=lambda obs: obs.date.jd)


        # pass down the provisional name so the table lines are linked to this TNO
        self.ssos_parser=SSOSParser(mpc_observations[0].provisional_name,
                                    input_observations=mpc_observations)

        self.orbit = Orbfit(mpc_observations)

        print self.orbit
        print self.orbit.residuals

        self.orbit.predict('2013-04-01')  # HARDWIRING FOR E BLOCK FOR NOW
        coord1 = self.orbit.coordinate
        self.orbit.predict('2013-05-01')
        coord2 = self.orbit.coordinate
        motion_rate = coord1.separation(coord2).arcsecs/(self.orbit.arc_length*60.)  # how best to get arcsec moved between first/last?
        print "{:>10s} {:8.2f}".format('rate ("/hr)', motion_rate)

        self.orbit.predict('2014-04-04')  # hardwiring next year's prediction date for the moment
        print "{:>10s} {:8.2f} {:8.2f}\n".format("Expected accuracy on 4 April 2014 (arcsec)", self.orbit.dra, self.orbit.ddec)

        length_of_observation_arc = mpc_observations[-1].date.jd - mpc_observations[0].date.jd

        if  length_of_observation_arc < 1:
            # data from the same dark run.
            lunation_count = 0
        elif length_of_observation_arc > 1 and length_of_observation_arc < self._nights_per_darkrun :
            # data from neighbouring darkruns.
            lunation_count = 1
        else:
            # data from the entire project.
            lunation_count = None

        # loop over the query until some new observations are found, or raise assert error.
        while True:
            tracks_data = self.query_ssos(mpc_observations, lunation_count)

            print len(mpc_observations), tracks_data.get_reading_count(), lunation_count
            if ( tracks_data.get_arc_length() > length_of_observation_arc or
                tracks_data.get_reading_count() > len(mpc_observations) ) :
                return tracks_data
            assert lunation_count is not None, "No new observations available."
            lunation_count += 1
            if lunation_count > 2 :
                lunation_count = None
Example #3
0
File: orbits.py Project: OSSOS/MOP
def summarize(orbit):
    for observation in orbit.observations:
            print observation.to_string()

    orbit = Orbfit(orbit.observations)

    print ""
    print orbit

    orbit.predict(orbit.observations[0].date)
    coord1 = orbit.coordinate
    orbit.predict(orbit.observations[-1].date)
    coord2 = orbit.coordinate
    motion_rate = coord1.separation(coord2).arcsecs/(orbit.arc_length*24)  # how best to get arcsec moved between first/last?
    print "{:>10s} {:8.2f}".format('rate ("/hr)', motion_rate)

    orbit.predict('2014-04-04')  # hardwiring next year's prediction date for the moment
    print "{:>10s} {:8.2f} {:8.2f}\n".format("Expected accuracy on 4 April 2014 (arcsec)", orbit.dra, orbit.ddec)

    return
Example #4
0
def summarize(orbit):
    for observation in orbit.observations:
        print(observation.to_string())

    orbit = Orbfit(orbit.observations)

    print("")
    print(orbit)

    orbit.predict(orbit.observations[0].date)
    coord1 = orbit.coordinate
    orbit.predict(orbit.observations[-1].date)
    coord2 = orbit.coordinate
    motion_rate = coord1.separation(coord2).arcsecs / (
        orbit.arc_length * 24
    )  # how best to get arcsec moved between first/last?
    print("{:>10s} {:8.2f}".format('rate ("/hr)', motion_rate))

    orbit.predict(
        '2014-04-04')  # hardwiring next year's prediction date for the moment
    print("{:>10s} {:8.2f} {:8.2f}\n".format(
        "Expected accuracy on 4 April 2014 (arcsec)", orbit.dra, orbit.ddec))

    return
Example #5
0
File: ssos.py Project: R136a1-/MOP
class TracksParser(object):

    def __init__(self, inspect=True):
        self._nights_per_darkrun = 18
        self._nights_separating_darkruns = 30
        self.inspect = inspect

    def parse(self, filename):
        filehandle = storage.open_vos_or_local(filename, "rb")
        filestr = filehandle.read()
        filehandle.close()

        input_mpc_lines = filestr.split('\n')

        mpc_observations = []
        for line in input_mpc_lines:
            mpc_observation = mpc.Observation.from_string(line)
            if mpc_observation is not None:
                mpc_observations.append(mpc_observation)

        mpc_observations.sort(key=lambda obs: obs.date.jd)


        # pass down the provisional name so the table lines are linked to this TNO
        self.ssos_parser=SSOSParser(mpc_observations[0].provisional_name,
                                    input_observations=mpc_observations)

        self.orbit = Orbfit(mpc_observations)

        for observation in self.orbit.observations:
            print observation.to_string()
        print ""
        print self.orbit
        print self.orbit.residuals

        self.orbit.predict(self.orbit.observations[0].date)
        coord1 = self.orbit.coordinate
        self.orbit.predict(self.orbit.observations[-1].date)
        coord2 = self.orbit.coordinate
        motion_rate = coord1.separation(coord2).arcsecs/(self.orbit.arc_length*24)  # how best to get arcsec moved between first/last?
        print "{:>10s} {:8.2f}".format('rate ("/hr)', motion_rate)

        self.orbit.predict('2014-04-04')  # hardwiring next year's prediction date for the moment
        print "{:>10s} {:8.2f} {:8.2f}\n".format("Expected accuracy on 4 April 2014 (arcsec)", self.orbit.dra, self.orbit.ddec)

        length_of_observation_arc = mpc_observations[-1].date.jd - mpc_observations[0].date.jd

        if length_of_observation_arc < 1:
            # data from the same dark run.
            lunation_count = 0
        elif length_of_observation_arc > 1 and length_of_observation_arc < self._nights_per_darkrun :
            # data from neighbouring darkruns.
            lunation_count = 1
        else:
            # data from the entire project.
            lunation_count = None

        # loop over the query until some new observations are found, or raise assert error.
        while True:
            tracks_data = self.query_ssos(mpc_observations, lunation_count)

            print len(mpc_observations), tracks_data.get_reading_count(), lunation_count


            if ( tracks_data.get_arc_length() > (length_of_observation_arc+2.0/86400.0) or
                tracks_data.get_reading_count() > len(mpc_observations) ) :
                return tracks_data
            if not self.inspect:
                assert lunation_count is not None, "No new observations available."
            if lunation_count is None:
                return tracks_data
            lunation_count += 1
            if lunation_count > 2 :
                lunation_count = None

    def query_ssos(self, mpc_observations, lunation_count=None):
        # we observe ~ a week either side of new moon
        # but we don't know when in the dark run the discovery happened
        # so be generous with the search boundaries, add extra 2 weeks
        # current date just has to be the night of the triplet,

        """

        :param mpc_observations: a list of mpc.Observations
        :param lunation_count: how many dark runs (+ and -) to search into
        :return: an SSOSData object
        """
        if lunation_count is None:
            search_start_date = Time('2013-02-08', scale='utc')
            search_end_date = Time(datetime.datetime.now().strftime('%Y-%m-%d'), scale='utc')
        else:
            search_start_date = Time((mpc_observations[0].date.jd - (
                self._nights_per_darkrun +
                lunation_count*self._nights_separating_darkruns) ),
                                     format='jd', scale='utc')
            search_end_date = Time((mpc_observations[-1].date.jd + (
                self._nights_per_darkrun +
                lunation_count*self._nights_separating_darkruns) ),
                                   format='jd', scale='utc')

        query = Query(mpc_observations,
                      search_start_date=search_start_date,
                      search_end_date=search_end_date)
        tracks_data = self.ssos_parser.parse(query.get())

        tracks_data.mpc_observations = {}
        for mpc_observation in mpc_observations:
            # attach the input observations to the the SSOS query result.
            assert isinstance(mpc_observation,mpc.Observation)
            tracks_data.mpc_observations[mpc_observation.comment.frame] = mpc_observation

        for source in tracks_data.get_sources():
            astrom_observations = tracks_data.observations
            source_readings = source.get_readings()
            for idx in range(len(source_readings)):
                source_reading = source_readings[idx]
                astrom_observation = astrom_observations[idx]
                logger.info("About to call orbfit predict")
                self.orbit.predict(astrom_observation.header['MJD_OBS_CENTER'])
                logger.info("Finished predict")
                source_reading.pa = self.orbit.pa
                # why are these being recorded just in pixels?
                source_reading.dra = self.orbit.dra / astrom_observation.header['SCALE']
                source_reading.ddec = self.orbit.ddec / astrom_observation.header['SCALE']

                frame = astrom_observation.rawname
                if frame in tracks_data.mpc_observations:
                    source_reading.discovery = tracks_data.mpc_observations[frame].discovery

        return tracks_data  # a SSOSData with .sources and .observations only
Example #6
0
 def print_orbfit_info(self):
     #TODO: this should not be here.
     print Orbfit(
         self.get_writer().get_chronological_buffered_observations())
Example #7
0
from ossos.orbfit import Orbfit

date = '2016-10-24T16:00:00'
# lightcurve_targets = '/Users/michele/Dropbox/Telescope proposals/Subaru ' \
#                      'proposal_2015A_lightcurves/lightcurve_targets.txt'
ossinpath = '/Users/bannisterm/Dropbox/OSSOS/measure3/ossin/tmp/'  #'vos:OSSOS/dbaseclone/ast/'  #
outfile = '/Users/bannisterm/Desktop/{}.txt'.format(date)
# '/Users/michele/Dropbox/Telescope proposals/Subaru proposal/lc_pos_20150414.txt'

with open(outfile, 'w') as ofile:
    ofile.write(
        'Target	RA (hrs)	DEC		m_r	delta RA (")	delta DEC (")	Time predicted\n')

# with open(lightcurve_targets, 'r') as infile:
#     lines = infile.readlines()
#     for line in lines:
#         obj, mag = line.split('\t')
for kbo_filename in os.listdir(ossinpath):
    mpc_observations = mpc.MPCReader(ossinpath + kbo_filename).mpc_observations
    orbit = Orbfit(mpc_observations)
    orbit.predict(date=date)

    with open(outfile, 'a') as ofile:
        ofile.write("{:>10s} {:>10s} {:6.2f} {:6.2f} {:>10s}\n".format(
            orbit.name,
            orbit.coordinate.to_string('hmsdms', sep=':'),
            # orbit.coordinate.dec.to_string('hmsdms'),  # need to add mag back in
            orbit.dra,
            orbit.ddec,
            date))
Example #8
0
from astropy import units as u

from ossos import mpc
from ossos import storage
from ossos.orbfit import Orbfit

date = '2016-10-24T16:00:00'
# lightcurve_targets = '/Users/michele/Dropbox/Telescope proposals/Subaru ' \
#                      'proposal_2015A_lightcurves/lightcurve_targets.txt'
ossinpath = '/Users/bannisterm/Dropbox/OSSOS/measure3/ossin/tmp/' #'vos:OSSOS/dbaseclone/ast/'  #
outfile = '/Users/bannisterm/Desktop/{}.txt'.format(date)
# '/Users/michele/Dropbox/Telescope proposals/Subaru proposal/lc_pos_20150414.txt'

with open(outfile, 'w') as ofile:
    ofile.write('Target	RA (hrs)	DEC		m_r	delta RA (")	delta DEC (")	Time predicted\n')

# with open(lightcurve_targets, 'r') as infile:
#     lines = infile.readlines()
#     for line in lines:
#         obj, mag = line.split('\t')
for kbo_filename in os.listdir(ossinpath):
    mpc_observations = mpc.MPCReader(ossinpath + kbo_filename).mpc_observations
    orbit = Orbfit(mpc_observations)
    orbit.predict(date=date)

    with open(outfile, 'a') as ofile:
        ofile.write("{:>10s} {:>10s} {:6.2f} {:6.2f} {:>10s}\n".format(
            orbit.name, orbit.coordinate.to_string('hmsdms', sep=':'),
            # orbit.coordinate.dec.to_string('hmsdms'),  # need to add mag back in
            orbit.dra, orbit.ddec, date))