예제 #1
0
def RAhDecd2xy(RA,DEC,obs):
   o = ephem.FixedBody()
   o._ra = ephem.degrees(RA*15*pi/180)
   o._dec = ephem.degrees(DEC*pi/180)
   o._epoch = ephem.J2000
   o.compute(obs)
   clip=False 
   if o.alt*180.0/pi < 30: clip=True
   x = (pi/2-o.alt)*180/pi*sin(o.az)
   y = (pi/2-o.alt)*180/pi*cos(o.az)
   return (x,y,clip)
예제 #2
0
def detail(request, object_id):
   obj = Object.objects.get(id=object_id)
   message = None
   error = None
   extras = "?"
   epoch = None
   tz_offset = 0
   if 'object_list_form' in request.session:
      tz_offset = float(request.session['object_list_form']['tz_offset'])
      if tz_offset is None:
         tz_offset = 0

   date = get_current_time(request)
   obj.epoch = date
   

   if request.method == 'POST':
      if 'action' in request.POST:
         if request.POST['action'] == 'GOTO':
            request.session['prev_tel_obj'] = request.session.get('cur_tel_obj',
                                                                  'Park')
            request.session['cur_tel_obj'] = obj.name
            request.session['tel_status'] = 'SLEW'
         elif request.POST['action'] == "Sync":
            request.session['prev_tel_obj'] = request.session.get('cur_tel_obj',
                                                                  'Park')
            request.session['tel_status'] = 'IDLE'
         elif request.POST['action'] == "Cancel":
            request.session['cur_tel_obj'] = request.session.get('prev_tel_obj',
                                                                 'Park')
            request.session['tel_status'] = 'IDLE'
         elif request.POST['action'] == "Update":
            comments = request.POST['comments']
            rating = int(request.POST.get('rating',0))
            obj.comments = comments
            obj.rating = rating
            obj.save()

      elif 'eyepiece' in request.POST:
         request.session['cur_eye'] = request.POST['eyepiece']

   cur_tel_obj = request.session.get('cur_tel_obj', 'Park')
   prev_tel_obj = request.session.get('prev_tel_obj', 'Park')
   tel_status = request.session.get('tel_status', 'IDLE')

   eyepiece = request.session.get('cur_eye', None)
   if eyepiece is not None:
      FOV = settings.fovs[eyepiece]
   else:
      FOV = settings.FINDER_SIZE

   if FOV != settings.FINDER_BASE_SIZE:
      extras += "size=%d&" % (FOV)
   if settings.FINDER_REVERSE:
      extras += "reverse=1&"
   if settings.FINDER_LOW:
      extras += "low=%d&" % (settings.FINDER_LOW)
   if settings.FINDER_HIGH:
      extras += "high=%d&" % (settings.FINDER_HIGH)
   extras = extras[:-1]     # cleanup trailing & or ?
   t = loader.get_template('navigator/object_detail.html')

   # Now deal with telescope position
   if tel_status == "SLEW":
      tel_RA,tel_DEC,tel_ha,tel_alt,tel_az = telescope_position(prev_tel_obj, date)
      new_RA,new_DEC,new_ha,new_alt,new_az = telescope_position(cur_tel_obj, date)
      # Now we move the dome
      delta_az = float(new_az) - float(tel_az)
      if delta_az < -180:
         delta_az += 360
      elif delta_az > 180:
         delta_az -= 360
      if delta_az > 0:
         az_move = "Dome Right %.2f" % (delta_az)
      else:
         az_move = "Dome Left %.2f" % (-delta_az)

      # Now we move in RA
      delta_ra = (ephem.hours(new_RA) - ephem.hours(tel_RA))/pi*12.
      if delta_ra < 0:
         ra_move = "Slew West %.2f h" % (abs(delta_ra))
      else:
         ra_move = "Slew East %.2f h" % (abs(delta_ra))

      # Now we move in DEC
      delta_dec = (ephem.degrees(new_DEC) - ephem.degrees(tel_DEC))/pi*180
      if delta_dec < -180:  delta_dec += 180
      if delta_dec > 180: delta_dec -= 180
      if delta_dec < 0:
         dec_move = "Slew South %.2f" % (abs(delta_dec))
      else:
         dec_move = "Slew North %.2f" % (abs(delta_dec))


   else:
      az_move = None
      ra_move = None
      dec_move = None
      tel_RA,tel_DEC,tel_ha,tel_alt,tel_az = telescope_position(cur_tel_obj, date)
   embed_plot = plot_objs.plot_alt_map([obj], date=date, toff=tz_offset) 
   c = RequestContext(request, {
      'object':obj, 'extras':extras, 
      'finder_orientation':settings.FINDER_ORIENTATION, 
      'finder_size':FOV,
      'eyepieces':settings.fovs,'cur_eyepiece':eyepiece,
      'message':message, 'error':error, 'epoch':epoch,
      'tel_RA':tel_RA,'tel_DEC':tel_DEC,'tel_ha':tel_ha,'tel_alt':tel_alt,
      'tel_az':tel_az, 'tel_status':tel_status, 'az_move':az_move,
      'ra_move':ra_move, 'dec_move':dec_move, 'embed_plot':embed_plot,
      })
   return HttpResponse(t.render(c))
예제 #3
0
def angle2dms(value):
   d = ephem.degrees(value*pi/180.)
   return(str(d))