;+ ; NAME: ; qEphem_State ; PURPOSE: ; Gets positions from ephemeris ; CATEGORY: ; sat/widget/qephem ; CALLING SEQUENCE: FUNCTION qEphem_State, state, event, send=send, silent=silent ; INPUTS: ; state ; OPTIONAL INPUT PARAMETERS: ; /send ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; IsType, InitVar, TimeSet, big_eph, AngleUnits ; smei_star_list ; PROCEDURE: ; MODIFICATION HISTORY: ; JUL-2005, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- ephem_state = {QEPHEMERIS_SEND, ID:0L, TOP:0L, HANDLER:0L, $ on : 0 , $ jpls : 0L , $ usnos : 0L , $ mpcs : 0L , $ stars : 0L , $ m_min : -2.0 , $ m_max : 1.0 , $ mark : '' , $ size : 1.0 , $ time : !TheTime , $ body : '' , $ center : '' } IF IsType(state,/undefined) THEN $ RETURN, ephem_state InitVar, send , /key InitVar, silent, /key ; Pick up values from qEphem widget, and put them in the ; ephem_state vector that will be send back to the qimage_cw widget ; ephem_state.on indicates whether qimage_cw needs to recalculate ; the ephemeris information (not necessary when wid_mark or wid_size ; events are processed, for instance). widget_control, state.wid_jpl , get_uvalue=tmp ephem_state.jpls = tmp ephem_state.on OR= event.id EQ state.wid_jpl widget_control, state.wid_usno , get_uvalue=tmp ephem_state.usnos = tmp ephem_state.on OR= event.id EQ state.wid_usno widget_control, state.wid_mpc , get_uvalue=tmp ephem_state.mpcs = tmp ephem_state.on OR= event.id EQ state.wid_mpc widget_control, state.wid_star , get_uvalue=tmp ephem_state.stars = tmp ephem_state.on OR= event.id EQ state.wid_star widget_control, state.wid_m_min, get_value=tmp ephem_state.m_min = tmp ephem_state.on OR= event.id EQ state.wid_m_min widget_control, state.wid_m_max, get_value=tmp ephem_state.m_max = tmp ephem_state.on OR= event.id EQ state.wid_m_max widget_control, state.wid_mark , get_value=tmp ephem_state.mark = tmp[widget_info(state.wid_mark, /droplist_select)] widget_control, state.wid_size , get_value=tmp ephem_state.size = tmp widget_control, state.wid_time , get_value=tmp ephem_state.on OR= event.id EQ state.wid_time CASE strpos(tmp,',') EQ -1 OF 0: BEGIN tmp = strtok(tmp,',',/extract) tmp = TimeSet(tmp[0],format=tmp[1]) END 1: tmp = TimeSet(tmp) ENDCASE ephem_state.time = tmp widget_control, state.wid_body , get_value=tmp ephem_state.body = tmp[0] ephem_state.on OR= event.id EQ state.wid_body widget_control, state.wid_center, get_value=tmp ephem_state.center = tmp[widget_info(state.wid_center, /droplist_select)] ephem_state.on OR= event.id EQ state.wid_center IF event.id EQ state.wid_exit THEN ephem_state.on = 0 CASE send OF 0: BEGIN rr = big_eph(state=ephem_state, tt, names=names, count=count, $ /to_sphere, /to_equatorial, /clean, /degrees) CASE count EQ 0 OF 0: BEGIN ra_dec = AngleUnits(from_angle=rr[0:1,*],/to_almanac,/strings,/degrees) ; Try to determine magnitudes mags = replicate(BadValue(0.0),count) found = jpl_body(names) n = where(found NE -1) IF n[0] NE -1 THEN mags[n] = jpl_mag(tt,found[n]) found = smei_star_list(name=names,/silent) n = where(smei_star_info(found,/get_name) NE '') IF n[0] NE -1 THEN mags[n] = smei_star_info(found[n],/get_mags) names = string(names,format='(A11)')+' '+ $ ra_dec[0,*]+' '+ $ ra_dec[1,*]+' '+ $ string(rr[2,*],format='(F9.4)')+' '+$ string(mags,format='(F7.2)') names = [ $ string('@'+ephem_state.center,format='(A13)')+ $ string('RA' ,format='(A9 )')+ $ string('Dec' ,format='(A15)')+ $ string('R (AU)' ,format='(A17)')+ $ string('M' ,format='(A9 )'),names] CASE n_elements(names) GT 80 OF 0: tmp = dialog_message(/info, dialog_parent=state.wid_info, names) 1: tmp = dialog_message(/info, dialog_parent=state.wid_info, 'Too many bodies listed') ENDCASE END 1: tmp = dialog_message(/info, dialog_parent=state.wid_info, 'No matching bodies found') ENDCASE END 1: IF widget_info(state.wid_send, /valid) THEN widget_control, state.wid_send, send_event=ephem_state ENDCASE RETURN, ephem_state & END