Export the trajectory JSON file.
Note
It is assumed that all the data is present in the segments needed to propagate.
Type | Intent | Optional | Attributes | Name | ||
---|---|---|---|---|---|---|
class(mission_type), | intent(inout) | :: | me | |||
character(len=*), | intent(in) | :: | filename |
plot file name [without extension] |
||
logical, | intent(in), | optional | :: | only_first_rev |
to only do the first rev [Default is False] |
subroutine export_trajectory_json_file(me,filename,only_first_rev) implicit none class(mission_type),intent(inout) :: me character(len=*),intent(in) :: filename !! plot file name [without extension] logical,intent(in),optional :: only_first_rev !! to only do the first rev [Default is False] integer :: iseg !! segment number counter integer :: nsegs_to_plot !! number of segments to plot type(json_core) :: json type(json_value),pointer :: p_root, p_segs, p_seg, p_current ! optional arguments: nsegs_to_plot = size(me%segs) ! default export all the segments if (present(only_first_rev)) then if (only_first_rev) nsegs_to_plot = 8 ! only the first rev (8 segments) end if ! the JSON file will contain an array of segments: call json%initialize(compress_vectors=.true.) call json%create_object(p_root, '') call json%create_array(p_segs, 'segs') call json%add(p_root, p_segs) p_current => null() do iseg = 1, nsegs_to_plot call destroy_traj(iseg) ! generate the trajectory for this segment: call me%segs(iseg)%propagate(mode=2) ! [export points] ! create the segment object for exporting the trajectory: call json%create_object(p_seg, '') if (associated(p_current)) then call json%insert_after(p_current, p_seg) ! next one else call json%add(p_segs, p_seg) ! first one end if p_current => p_seg ! update for next seg call json%add(p_seg, 'iseg', iseg) call json%add(p_seg, 'et', me%segs(iseg)%traj_inertial%et) call json%add(p_seg, 'x_inertial', me%segs(iseg)%traj_inertial%x) call json%add(p_seg, 'y_inertial', me%segs(iseg)%traj_inertial%y) call json%add(p_seg, 'z_inertial', me%segs(iseg)%traj_inertial%z) call json%add(p_seg, 'vx_inertial', me%segs(iseg)%traj_inertial%vx) call json%add(p_seg, 'vy_inertial', me%segs(iseg)%traj_inertial%vy) call json%add(p_seg, 'vz_inertial', me%segs(iseg)%traj_inertial%vz) call json%add(p_seg, 'x_rotating', me%segs(iseg)%traj_rotating%x) call json%add(p_seg, 'y_rotating', me%segs(iseg)%traj_rotating%y) call json%add(p_seg, 'z_rotating', me%segs(iseg)%traj_rotating%z) ! call json%add(p_seg, 'vx_rotating', me%segs(iseg)%traj_rotating%vx) ! call json%add(p_seg, 'vy_rotating', me%segs(iseg)%traj_rotating%vy) ! call json%add(p_seg, 'vz_rotating', me%segs(iseg)%traj_rotating%vz) call json%add(p_seg, 'x_se_rotating', me%segs(iseg)%traj_se_rotating%x) call json%add(p_seg, 'y_se_rotating', me%segs(iseg)%traj_se_rotating%y) call json%add(p_seg, 'z_se_rotating', me%segs(iseg)%traj_se_rotating%z) ! call json%add(p_seg, 'vx_se_rotating', me%segs(iseg)%traj_se_rotating%vx) ! don't need these ! call json%add(p_seg, 'vy_se_rotating', me%segs(iseg)%traj_se_rotating%vy) ! call json%add(p_seg, 'vz_se_rotating', me%segs(iseg)%traj_se_rotating%vz) !TODO: ! - maybe also earth & sun ephemeris for plotting ! - solar fraction to color the trajectory [but really that should go in the eclipse file?] call destroy_traj(iseg) ! keep them for the eclipse file generation ... end do call json%print(p_root, trim(filename)//'.json') call json%destroy(p_root) contains subroutine destroy_traj(iseg) integer,intent(in) :: iseg !! segment number call me%segs(iseg)%traj_inertial%destroy() call me%segs(iseg)%traj_rotating%destroy() call me%segs(iseg)%traj_se_rotating%destroy() end subroutine destroy_traj end subroutine export_trajectory_json_file