def allowedPos(world_pos, date): """ This routine can be used to check whether WFIRST would be allowed to look at a particular position (`world_pos`) on a given `date`. This is determined by the angle of this position relative to the Sun. In general, WFIRST can point at angles relative to the Sun in the range 90+/-36 degrees. Obviously, pointing too close to the Sun would result in overly high sky backgrounds. It is less obvious why WFIRST cannot look at a spot directly opposite from the Sun (180 degrees on the sky). The reason is that the observatory is aligned such that if the observer is looking at some sky position, the solar panels are oriented at 90 degrees from that position. So it's always optimal for the observatory to be pointing at an angle of 90 degrees relative to the Sun. It is also permitted to look within 36 degrees of that optimal position. @param world_pos A galsim.CelestialCoord indicating the position at which the observer wishes to look. @param date A python datetime object indicating the desired date of observation. @returns True or False, indicating whether it is permitted to look at this position on this date. """ # Find the Sun's location on the sky on this date. from galsim.celestial import _ecliptic_to_equatorial, _sun_position_ecliptic sun = _ecliptic_to_equatorial(_sun_position_ecliptic(date), date.year) # Find the angle between that and the supplied position angle_deg = abs(world_pos.distanceTo(sun)/galsim.degrees) # Check if it's within tolerance. min_ang = 90. - 36. max_ang = 90. + 36. return angle_deg >= min_ang and angle_deg <= max_ang
def allowedPos(world_pos, date): """ This routine can be used to check whether WFIRST would be allowed to look at a particular position (`world_pos`) on a given `date`. This is determined by the angle of this position relative to the Sun. In general, WFIRST can point at angles relative to the Sun in the range 90+/-36 degrees. Obviously, pointing too close to the Sun would result in overly high sky backgrounds. It is less obvious why WFIRST cannot look at a spot directly opposite from the Sun (180 degrees on the sky). The reason is that the observatory is aligned such that if the observer is looking at some sky position, the solar panels are oriented at 90 degrees from that position. So it's always optimal for the observatory to be pointing at an angle of 90 degrees relative to the Sun. It is also permitted to look within 36 degrees of that optimal position. @param world_pos A galsim.CelestialCoord indicating the position at which the observer wishes to look. @param date A python datetime object indicating the desired date of observation. @returns True or False, indicating whether it is permitted to look at this position on this date. """ # Find the Sun's location on the sky on this date. from galsim.celestial import _ecliptic_to_equatorial, _sun_position_ecliptic sun = _ecliptic_to_equatorial(_sun_position_ecliptic(date), date.year) # Find the angle between that and the supplied position angle_deg = abs(world_pos.distanceTo(sun) / galsim.degrees) # Check if it's within tolerance. min_ang = 90. - 36. max_ang = 90. + 36. return angle_deg >= min_ang and angle_deg <= max_ang
def bestPA(world_pos, date): """ This routine determines the best position angle for the observatory for a given observation date and position on the sky. The best/optimal position angle is determined by the fact that the solar panels are at 90 degrees to the position being observed, and it is best to have those facing the Sun as directly as possible. Note that if a given `world_pos` is not actually observable on the given `date`, then this routine will return None. @param world_pos A galsim.CelestialCoord indicating the position at which the observer wishes to look. @param date A python datetime object indicating the desired date of observation. @returns the best position angle for the observatory, as a galsim.Angle, or None if the position is not observable. """ # First check for observability. if not allowedPos(world_pos, date): return None # Find the location of the sun on this date. +X_observatory points out into the sky, towards # world_pos, while +Z is in the plane of the sky pointing towards the sun as much as possible. from galsim.celestial import _ecliptic_to_equatorial, _sun_position_ecliptic sun = _ecliptic_to_equatorial(_sun_position_ecliptic(date), date.year) # Now we do a projection onto the sky centered at world_pos to find the (u, v) for the Sun. sun_tp = world_pos.project(sun, 'gnomonic') # We want to rotate around by 90 degrees to find the +Y obs direction. Specifically, we want # (+X, +Y, +Z)_obs to form a right-handed coordinate system. y_obs_tp = galsim.PositionD(-sun_tp.y, sun_tp.x) y_obs = world_pos.deproject(y_obs_tp, 'gnomonic') # Finally the observatory position angle is defined by the angle between +Y_observatory and the # celestial north pole. It is defined as position angle east of north. north = galsim.CelestialCoord(y_obs.ra, 90.*galsim.degrees) obs_pa = world_pos.angleBetween(y_obs, north) return obs_pa
def bestPA(world_pos, date): """ This routine determines the best position angle for the observatory for a given observation date and position on the sky. The best/optimal position angle is determined by the fact that the solar panels are at 90 degrees to the position being observed, and it is best to have those facing the Sun as directly as possible. Note that if a given `world_pos` is not actually observable on the given `date`, then this routine will return None. @param world_pos A galsim.CelestialCoord indicating the position at which the observer wishes to look. @param date A python datetime object indicating the desired date of observation. @returns the best position angle for the observatory, as a galsim.Angle, or None if the position is not observable. """ # First check for observability. if not allowedPos(world_pos, date): return None # Find the location of the sun on this date. +X_observatory points out into the sky, towards # world_pos, while +Z is in the plane of the sky pointing towards the sun as much as possible. from galsim.celestial import _ecliptic_to_equatorial, _sun_position_ecliptic sun = _ecliptic_to_equatorial(_sun_position_ecliptic(date), date.year) # Now we do a projection onto the sky centered at world_pos to find the (u, v) for the Sun. sun_tp = world_pos.project(sun, 'gnomonic') # We want to rotate around by 90 degrees to find the +Y obs direction. Specifically, we want # (+X, +Y, +Z)_obs to form a right-handed coordinate system. y_obs_tp = galsim.PositionD(-sun_tp.y, sun_tp.x) y_obs = world_pos.deproject(y_obs_tp, 'gnomonic') # Finally the observatory position angle is defined by the angle between +Y_observatory and the # celestial north pole. It is defined as position angle east of north. north = galsim.CelestialCoord(y_obs.ra, 90. * galsim.degrees) obs_pa = world_pos.angleBetween(y_obs, north) return obs_pa