Commit c182b816 authored by Reza  ANSARI's avatar Reza ANSARI
Browse files

Merge branch 'master' of gitlab.in2p3.fr:baoradio/AnaPAON4

  Reza: j'ai fait des modifs sur trkfit.cc et trkacxfit.cc - et des fichiers modifies sur le repo (22/02/2019)
parents 4d75328a 9a81ff61
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="jdk" jdkName="Python 3.6 (py365)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.6 (py365)" project-jdk-type="Python SDK" />
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/altaz.iml" filepath="$PROJECT_DIR$/.idea/altaz.iml" />
</modules>
</component>
</project>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="34cdaa68-9aba-4f5d-94e0-75816b88bf13" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/altaz.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="260">
<caret line="214" column="28" lean-forward="true" selection-start-line="214" selection-start-column="28" selection-end-line="214" selection-end-column="28" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/../../../../../kits/anaconda3/envs/py365/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2934">
<caret line="549" column="60" selection-start-line="549" selection-start-column="57" selection-end-line="549" selection-end-column="60" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="FindInProjectRecents">
<findStrings>
<find>lat</find>
</findStrings>
<replaceStrings>
<replace>source</replace>
<replace>scan_source</replace>
</replaceStrings>
</component>
<component name="IdeDocumentHistory">
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/altaz.py" />
</list>
</option>
</component>
<component name="ProjectFrameBounds">
<option name="x" value="280" />
<option name="y" value="125" />
<option name="width" value="1634" />
<option name="height" value="967" />
</component>
<component name="ProjectView">
<navigator proportions="" version="1">
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
<path>
<item name="altaz" type="b2602c69:ProjectViewProjectNode" />
<item name="altaz" type="462c0819:PsiDirectoryNode" />
</path>
</expand>
<select />
</subPane>
</pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="altaz" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="altaz" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/altaz.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.altaz" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="34cdaa68-9aba-4f5d-94e0-75816b88bf13" name="Default Changelist" comment="" />
<created>1550739331637</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1550739331637</updated>
</task>
<servers />
</component>
<component name="ToolWindowManager">
<frame x="280" y="125" width="1634" height="967" extended-state="0" />
<layout>
<window_info id="Favorites" side_tool="true" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.2132672" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info anchor="bottom" id="Version Control" />
<window_info anchor="bottom" id="Python Console" weight="0.32914287" />
<window_info anchor="bottom" id="Terminal" />
<window_info anchor="bottom" id="Event Log" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
<window_info anchor="bottom" id="Find" order="1" />
<window_info anchor="bottom" id="Run" order="2" weight="0.216" />
<window_info anchor="bottom" id="Debug" order="3" weight="0.4" />
<window_info anchor="bottom" id="Cvs" order="4" weight="0.25" />
<window_info anchor="bottom" id="Inspection" order="5" weight="0.4" />
<window_info anchor="bottom" id="TODO" order="6" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
</layout>
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/../../../../../kits/anaconda3/envs/py365/lib/python3.6/site-packages/astropy/coordinates/sky_coordinate.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="2934">
<caret line="549" column="60" selection-start-line="549" selection-start-column="57" selection-end-line="549" selection-end-column="60" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/altaz.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="260">
<caret line="214" column="28" lean-forward="true" selection-start-line="214" selection-start-column="28" selection-end-line="214" selection-end-column="28" />
<folding>
<element signature="e#0#18#0" expanded="true" />
</folding>
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
This diff is collapsed.
import numpy as np
import matplotlib
import matplotlib.pyplot as plt
from astropy.visualization import astropy_mpl_style
plt.style.use(astropy_mpl_style)
from astropy.coordinates import get_moon, get_sun
import astropy.units as u
from astropy.time import Time
from astropy.coordinates import SkyCoord, EarthLocation, AltAz
from astropy.coordinates import Angle
import argparse
def scan_source(source="Moon",
local_lat="47:22:55.1",
local_lon="2:11:58.7",
local_height=150,
t0="2019-1-14 00:00:00",
dt=5,
type="transit"):
"""
:param source: is the name of the source to track
:param local_lat: observer latitude
:param local_lon: observer longitude
:param local_height: observer height (informative [m])
:param t0: UTC middle time of the survey
:param dt: survey duration according to option in hour
:param type: transit [t0-dt,t0+dt]; range [t0, t0+dt]
:return:
"""
# Earth location of the observer
lat = local_lat.split(':')
lon = local_lon.split(':')
observer = EarthLocation(
lat=int(lat[0])*u.deg+int(lat[1])*u.arcmin+float(lat[2])*u.arcsec,
lon=int(lon[0])*u.deg+int(lon[1])*u.arcmin+float(lon[2])*u.arcsec,
height=float(local_height)*u.m
)
# survey
start = Time(t0,scale='utc')
if type.lower() == "transit":
# [t0 - dt, t0 + dt] ends included : 30sec step
delta_period = np.linspace(-dt, dt, 4*dt*60+1)*u.hour
else:
# [t0, t0 + dt] ends included : 30 sec step
delta_period = np.linspace(0, dt, 2*dt*60+1)*u.hour
times_period = start + delta_period
# Compute the Alt-Az frames during the survey
frame_period = AltAz(obstime=times_period, location=observer)
# perform the survey
source = source.lower()
if source == "moon":
survey = get_moon(times_period).transform_to(frame_period)
elif source == "sun":
survey = get_sun(times_period).transform_to(frame_period)
else:
survey = SkyCoord.from_name(source).transform_to(frame_period)
return survey, delta_period
def plot(surveys):
"""
:param surveys: dictionary
:return: None
In the followin example survey Moon, Sun, CasA and M1 during 5 days from reference date
>>> moon_survey,delta_period = scan_source("Moon",dt=24*5,option="range")
>>> sun_survey,__ = scan_source("Sun",dt=24*5,option="range")
>>> casa_survey,__ = scan_source("CasA",dt=24*5,option="range")
>>> crabe_survey,__ = scan_source("M1",dt=24*5,option="range")
>>> surveys = [
>>> {"kind": "plot","label": "Moon", "color":"k", "ls":"--", "survey": moon_survey, "period":delta_period},
>>> {"kind": "plot", "label": "Sun", "color":"r", "ls":None, "survey": sun_survey, "period": delta_period},
>>> {"kind": "scatter", "label": "CasA", "color": "jet", "ls": None, "survey": casa_survey, "period": delta_period},
>>> {"kind": "scatter", "label": "Crabe", "color": "viridis", "ls": None, "survey": crabe_survey, "period": delta_period}
>>> ]
>>> plot(surveys)
"""
matplotlib.rcParams.update({'font.size': 24})
fig = plt.figure(figsize=(30, 15))
norm = plt.Normalize(0, 360)
dictplot = {}
dictcolbar = {}
for idx,s in enumerate(surveys):
if s['kind'] == 'plot':
plt.plot(s['period'], s['survey'].alt, color=s['color'], label=s['label'], ls=s['ls'])
elif s['kind'] == 'scatter':
dictplot["i{0}".format(idx)] = plt.scatter(s['period'], s['survey'].alt,
c=s['survey'].az, s=8, marker='o',
cmap=s['color'], norm=norm)
dictcolbar["i{0}".format(idx)] = plt.colorbar(dictplot["i{0}".format(idx)])
dictcolbar["i{0}".format(idx)].set_label("{} Az [deg]".format(s['label']))
plt.legend(loc='upper left')
plt.ylim(0, 90)
plt.xlabel('Hours from Ref')
plt.ylabel('Altitude [deg]')
plt.show()
def write_survey(local_lat,
local_lon,
source,
survey,
tag):
"""
:param local_lat: observer latitude
:param local_lon: observer longitude
:param source: is the name of the source to track
:param survey: tracking list
:param tag: additional string to identify the output file
:return: none
"""
if tag is not None:
fname = f'{source}_survey{tag}.txt'
else:
fname = f'{source}_survey.txt'
print(f'{"Save tracking on file {fname}"}')
file = open(fname, "w")
file.write("#### Track for {}\n".format(source))
file.write("#### Observer lat:{} long:{}\n".format(local_lat,local_lon))
file.write("#### Use Galactic coordinate (l,b)\n")
file.write("#### %Y-%m-%d %H:%M:%S.%f Az(deg_dec) Alt(deg_dec) Range l(deg_dec) b(deg_dec) Altitude\n")
for i in survey:
long_lat_galactic = i.galactic
file.write(Time.strftime(i.obstime,'%Y-%m-%d %H:%M:%S.%f')
+f'{Angle(i.az).degree:10.4f}'
+f'{Angle(i.alt).degree:10.4f}'
+f'{1.e19:10.2E}'
+f'{long_lat_galactic.l.degree:10.4f}'
+f'{long_lat_galactic.b.degree:10.4f}'
+f'{1.e19:10.2E}'
+"\n"
)
file.close()
def add_args(parser):
""" Parse command line arguments
-src CasA -t0 "2019-1-14 15:39:00" -dt 1.0 -opt transit -tag "_1"
"""
# Arguments
parser.add_argument(
'-src', dest='source',
required=True,
default="CasA",
help='Source to track (CSD name): Moon, Sun, CasA, M1...')
parser.add_argument(
'-t0', dest='t0',
required=True,
help='Reference time ex. "2019-1-14 15:39:00" ')
parser.add_argument(
'-dt', dest='dt',
type=float,
default=1.,
help='survey duration according to option in hour. 1h default')
parser.add_argument(
'-type', dest='type',
default="transit",
help='transit =>[t0-dt,t0+dt] default; range=> [t0, t0+dt]')
parser.add_argument(
'-tag', dest='tag',
default=None,
help='a string that is used for the output file ex. "_1"')
if __name__ == '__main__' :
"""
Perform the tracking of source with observer at Nancay
ex.
altaz.py
-src CasA -t0 "2019-1-14 15:39:00" -dt 1.0 -type transit -tag "_1"
"""
# Argument decoding
arg_parser = argparse.ArgumentParser(description='Read args')
add_args(arg_parser)
args = arg_parser.parse_args(None)
# moon_survey,delta_period = scan_source("Moon",dt=24*5,option="range")
# sun_survey,__ = scan_source("Sun",dt=24*5,option="range")
# crabe_survey,__ = scan_source("M1",dt=24*5,option="range")
# extract the source CDS name
source = args.source
# extract the tracking type option
type_of_tracking = args.type
# observer lattitude, longitude
nancay_lat = "47:22:55.1"
nancay_lon = "2:11:58.7"
# perform the tracking
src_tracking,_= scan_source(source=source,
local_lat=nancay_lat,
local_lon=nancay_lon,
t0=args.t0,
dt=args.dt,
type=type_of_tracking)
# save on file the tracking
write_survey(local_lat=nancay_lat,
local_lon=nancay_lon,
source=source,
survey=src_tracking,
tag=args.tag)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment