get_rv_from_jpl_ephemeris Subroutine

private subroutine get_rv_from_jpl_ephemeris(me, et, targ, obs, rv, status_ok)

Uses

  • proc~~get_rv_from_jpl_ephemeris~~UsesGraph proc~get_rv_from_jpl_ephemeris jpl_ephemeris_module::jpl_ephemeris%get_rv_from_jpl_ephemeris module~celestial_body_module celestial_body_module proc~get_rv_from_jpl_ephemeris->module~celestial_body_module module~conversion_module conversion_module proc~get_rv_from_jpl_ephemeris->module~conversion_module module~numbers_module numbers_module proc~get_rv_from_jpl_ephemeris->module~numbers_module module~time_module time_module proc~get_rv_from_jpl_ephemeris->module~time_module module~celestial_body_module->module~numbers_module module~base_class_module base_class_module module~celestial_body_module->module~base_class_module module~kind_module kind_module module~celestial_body_module->module~kind_module module~conversion_module->module~numbers_module module~conversion_module->module~kind_module module~numbers_module->module~kind_module module~time_module->module~kind_module iso_fortran_env iso_fortran_env module~kind_module->iso_fortran_env

Interface for the ephemeris_module.

Type Bound

jpl_ephemeris

Arguments

Type IntentOptional Attributes Name
class(jpl_ephemeris), intent(inout) :: me
real(kind=fat_wp), intent(in) :: et

ephemeris time [sec]

type(celestial_body), intent(in) :: targ

target body

type(celestial_body), intent(in) :: obs

observer body

real(kind=fat_wp), intent(out), dimension(6) :: rv

state of targ w.r.t. obs [km,km/s] in ICRF frame

logical, intent(out) :: status_ok

true if there were no problems


Calls

proc~~get_rv_from_jpl_ephemeris~~CallsGraph proc~get_rv_from_jpl_ephemeris jpl_ephemeris_module::jpl_ephemeris%get_rv_from_jpl_ephemeris proc~et_to_jd time_module::et_to_jd proc~get_rv_from_jpl_ephemeris->proc~et_to_jd proc~get_state jpl_ephemeris_module::jpl_ephemeris%get_state proc~get_rv_from_jpl_ephemeris->proc~get_state proc~spice_id_to_old_id jpl_ephemeris_module::spice_id_to_old_id proc~get_rv_from_jpl_ephemeris->proc~spice_id_to_old_id proc~state jpl_ephemeris_module::jpl_ephemeris%state proc~get_state->proc~state proc~interp jpl_ephemeris_module::jpl_ephemeris%interp proc~state->proc~interp proc~split jpl_ephemeris_module::split proc~state->proc~split

Source Code

    subroutine get_rv_from_jpl_ephemeris(me,et,targ,obs,rv,status_ok)

    use time_module,           only: et_to_jd
    use conversion_module,     only: day2sec
    use celestial_body_module, only: celestial_body
    use numbers_module,        only: zero

    implicit none

    class(jpl_ephemeris),intent(inout)    :: me
    real(fat_wp),intent(in)               :: et         !! ephemeris time [sec]
    type(celestial_body),intent(in)       :: targ       !! target body
    type(celestial_body),intent(in)       :: obs        !! observer body
    real(fat_wp),dimension(6),intent(out) :: rv         !! state of targ w.r.t. obs [km,km/s] in ICRF frame
    logical,intent(out)                   :: status_ok  !! true if there were no problems

    real(wp) :: jd     !! julian date for input to [[get_state]].
    integer :: ntarg   !! id code for target body
    integer :: ncent   !! id code for observer body
    real(wp),dimension(6) :: rv_ !! in case `wp /= fat_wp` we need a copy

    if (targ==obs) then
        !don't bother if target and observer are the same body
        rv = zero
        status_ok = .true.
    else

        !convert to expected inputs:
        jd    = et_to_jd(et)
        ntarg = spice_id_to_old_id(targ%id)
        ncent = spice_id_to_old_id(obs%id)

        if (ntarg>0 .and. ncent>0) then
            call me%get_state(jd,ntarg,ncent,rv_,status_ok)
            rv = rv_
            if (status_ok) then
                if (.not. me%km) then
                    !we must return in units of km/s
                    !so, convert from AU, AU/day to km, km/s
                    rv      = rv * me%au
                    rv(4:6) = rv(4:6) / day2sec
                end if
            else
                write(error_unit,'(A)') 'Error in get_rv_from_jpl_ephemeris: '//&
                            'Error calling ephemeris.'
            end if
        else
            write(error_unit,'(A)') 'Error in get_rv_from_jpl_ephemeris: '//&
                        'No ephemeris for this body.'
            status_ok = .false.
        end if

    end if

    end subroutine get_rv_from_jpl_ephemeris