Check the shadow function along the whole trajectory (every eclipse_opt_detect_step
seconds), and make the rows of the segments that come near the shadow (where the shadow
function, with the constraints' bubble, is below eclipse_opt_detect_phi).
| Type | Intent | Optional | Attributes | Name | ||
|---|---|---|---|---|---|---|
| class(mission_type), | intent(inout) | :: | mission | |||
| real(kind=wp), | intent(in), | dimension(:) | :: | x | ||
| type(eclipse_row), | intent(out), | dimension(:), allocatable | :: | rows | ||
| real(kind=wp), | intent(out) | :: | phimin |
the smallest shadow function (no bubble) along the trajectory |
||
| real(kind=wp), | intent(out) | :: | shadow_min |
the time in the shadow [min] (approximate: the number of points in the shadow times the step) |
subroutine find_rows(mission, x, rows, phimin, shadow_min) class(mission_type),intent(inout) :: mission real(wp),dimension(:),intent(in) :: x type(eclipse_row),dimension(:),allocatable,intent(out) :: rows real(wp),intent(out) :: phimin !! the smallest shadow function (no bubble) along the trajectory real(wp),intent(out) :: shadow_min !! the time in the shadow [min] (approximate: the number of points !! in the shadow times the step) integer :: n_segs, iseg, i, n, n_full, nk, kmax, nr real(wp),dimension(:),allocatable :: seg_phimin, seg_lo, seg_hi integer,dimension(:),allocatable :: seg_nshadow, full2red, removed logical,dimension(:),allocatable :: seg_near real(wp) :: dt, phi0, phib, step real(wp),dimension(6) :: rv call mission%define_problem_size(n_segs=n_segs) call mission%define_problem_size(n=n_full, full_problem=.true.) call mission%put_x_in_segments(x) allocate(seg_phimin(n_segs), seg_lo(n_segs), seg_hi(n_segs), seg_nshadow(n_segs), seg_near(n_segs)) seg_phimin = huge(one); seg_lo = huge(one); seg_hi = -huge(one); seg_nshadow = 0; seg_near = .false. !$OMP PARALLEL DO PRIVATE(iseg,i,n,dt,phi0,phib,rv) SCHEDULE(dynamic) do iseg = 1, n_segs associate (seg => mission%segs(iseg)) call seg%traj_inertial%destroy() call seg%traj_rotating%destroy() call seg%traj_se_rotating%destroy() call seg%propagate(mode=2, tstep=mission%eclipse_opt_detect_step) n = size(seg%traj_inertial%et) do i = 1, n rv = [seg%traj_inertial%x(i), seg%traj_inertial%y(i), seg%traj_inertial%z(i), & seg%traj_inertial%vx(i), seg%traj_inertial%vy(i), seg%traj_inertial%vz(i)] phi0 = get_sun_fraction(seg%eph, seg%traj_inertial%et(i), rv, zero) if (mission%eclipse_opt_bubble > zero) then phib = get_sun_fraction(seg%eph, seg%traj_inertial%et(i), rv, mission%eclipse_opt_bubble) else phib = phi0 end if seg_phimin(iseg) = min(seg_phimin(iseg), phi0) if (phi0 < zero) seg_nshadow(iseg) = seg_nshadow(iseg) + 1 if (phib < mission%eclipse_opt_detect_phi) then dt = abs(seg%traj_inertial%et(i) - seg%traj_inertial%et(1)) ! [sec from the start] seg_near(iseg) = .true. seg_lo(iseg) = min(seg_lo(iseg), dt) seg_hi(iseg) = max(seg_hi(iseg), dt) end if end do call seg%traj_inertial%destroy() call seg%traj_rotating%destroy() call seg%traj_se_rotating%destroy() end associate end do !$OMP END PARALLEL DO phimin = minval(seg_phimin) shadow_min = real(sum(seg_nshadow),wp) * mission%eclipse_opt_detect_step / 60.0_wp ! the map from the full problem's columns to x: removed = mission%removed_columns() allocate(full2red(n_full)) full2red = 0 nk = 0 do i = 1, n_full if (any(removed==i)) cycle nk = nk + 1 full2red(i) = nk end do ! the rows: the samples across the near-shadow part of each flagged segment, padded by one ! sample on each side (and not past the segment's last full step) step = mission%eclipse_opt_sample_step allocate(rows(count(seg_near))) nr = 0 do iseg = 1, n_segs if (.not. seg_near(iseg)) cycle associate (seg => mission%segs(iseg)) kmax = floor(abs(seg%data%tf - seg%data%t0)*day2sec/step - 1.0e-6_wp) nr = nr + 1 rows(nr)%iseg = iseg rows(nr)%k_lo = max(0, floor(seg_lo(iseg)/step) - 1) rows(nr)%k_hi = min(kmax, ceiling(seg_hi(iseg)/step) + 1) call row_columns(iseg, full2red, rows(nr)) end associate end do end subroutine find_rows