Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Starshapes clarity kit #65

Merged
merged 49 commits into from
Sep 16, 2024
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
738dcbe
typo and China atmosphere models
lguelzow Jul 13, 2023
ab739f0
added some prints and reverted default obslevel
lguelzow Aug 22, 2023
4900905
removed prints from testphase
lguelzow Jul 3, 2024
31cb4de
update input variables and add descriptions (input stays the same)
lguelzow Jul 3, 2024
7f35e95
add optional rotation of stations and magnetic field to accomodate Co…
lguelzow Jul 3, 2024
623e0f0
update variable names and add documentation
lguelzow Jul 3, 2024
9cece20
more variable updates and documentation
lguelzow Jul 3, 2024
67609de
apply optional rotation and convert to cm for Corsika. Then write int…
lguelzow Jul 3, 2024
8688962
more documentation
lguelzow Jul 3, 2024
62279a8
add print to show saved file with antenna positions
lguelzow Jul 3, 2024
f432e1d
more variable name updates
lguelzow Jul 3, 2024
c795161
option for additional file in shower plane for visual checks
lguelzow Jul 3, 2024
f5b7c94
add sys import and correct parameter name error
lguelzow Jul 3, 2024
813bf68
remove deprecated module
lguelzow Jul 3, 2024
a390365
correct variable name
lguelzow Jul 3, 2024
b19845f
Merge branch 'starshapes_clarity_KIT' of https://github.com/nu-radio/…
lguelzow Jul 3, 2024
261aeb5
renamed position variable to unified name to make compatible with old…
lguelzow Jul 3, 2024
2c21f8a
updated slicing and gammacut sections with new variable name and adde…
lguelzow Jul 3, 2024
53319e0
Merge branch 'starshapes_clarity_KIT' of https://github.com/nu-radio/…
lguelzow Jul 3, 2024
f900998
remove deprecated package and change default obslevel to Auger value
lguelzow Jul 4, 2024
38ed414
add command to open the file
lguelzow Jul 4, 2024
56a9d51
fix variable typos
lguelzow Jul 4, 2024
8b90d73
add missing doc
lguelzow Jul 4, 2024
91d439a
error messages for wrong units
lguelzow Jul 4, 2024
d532236
new functions for generating antenna rings for the star shapes
lguelzow Jul 4, 2024
68758dc
reverted back to default number of antenna rings
lguelzow Jul 4, 2024
f63d37f
widen a range to make it for 50-200MHz frequency band
lguelzow Jul 4, 2024
72e8065
derpecated function
lguelzow Jul 27, 2024
6672758
more deprecations
lguelzow Jul 27, 2024
f5d59c1
Merge branch 'starshapes_clarity_KIT' of https://github.com/nu-radio/…
lguelzow Jul 27, 2024
90e96d9
modernise if clauses
lguelzow Jul 29, 2024
725acea
Merge branch 'starshapes_clarity_KIT' of https://github.com/nu-radio/…
lguelzow Jul 29, 2024
8197b0f
deprecated functions
lguelzow Jul 29, 2024
4f102ef
correction to errors
lguelzow Jul 29, 2024
a6c70f0
Merge branch 'starshapes_clarity_KIT' of https://github.com/nu-radio/…
lguelzow Jul 29, 2024
de9137c
add file with functions from Felix to estimate cherenkov radius
lguelzow Jul 31, 2024
6fafb8a
address documentation comments
lguelzow Jul 31, 2024
175eefb
change dependency to internal
lguelzow Jul 31, 2024
ab38e24
make warning and if conditions cleaner
lguelzow Jul 31, 2024
9533ba8
add clarity and documentation to new functions to generate starshape …
lguelzow Jul 31, 2024
3fa46ee
Merge branch 'master' into starshapes_clarity_KIT
lguelzow Jul 31, 2024
2ca721c
change ifs back bc it gave an error
lguelzow Aug 1, 2024
6d7cacb
revert to less elegant form bc it gave an error
lguelzow Aug 7, 2024
d9c15fc
Merge branch 'starshapes_clarity_KIT' of https://github.com/nu-radio/…
lguelzow Aug 7, 2024
1a2f81e
fix deprecated import
lguelzow Aug 7, 2024
74d97c6
remove unused, old function and removed "model" from function names
lguelzow Aug 20, 2024
48e384f
more model removal
lguelzow Aug 20, 2024
d2cfb74
made input parameters all lowercase
lguelzow Aug 20, 2024
0d8910e
removed rough rmax parametrisation and replaced it with multiples of …
lguelzow Aug 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
182 changes: 182 additions & 0 deletions radiotools/atmosphere/cherenkov_radius.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
# functions to estimate calculate the cherenkov radius of the radio emission of an air shower
# code written by Felix Schlueter for the RadioAnalysis framework
# added to radiotools by Lukas Guelzow

import numpy as np
import warnings

from radiotools.atmosphere import models as atm


def get_cherenkov_radius_model_from_depth(zenith, depth, obs_level, n0, model=None, at=None):
""" Calculates the radius of the (Cherenkov) cone with an apex at a given depth along a
shower axis with a given zenith angle. The open angle of the cone equals the
Cherenkov angle for a value of the refractive index at this position.

Paramter:

zenith : double
Zenith angle (in radian) under which a shower is observed

depth : double
Slant depth (in g/cm^2), i.e., shower maximum of the observed shower

obs_level : double
Altitude (in meter) of the plane at which the shower is observed

n0 : double
Refractive index at sea level (!= obs_level)

model : int
Model index for the atmospheric (density) profile model. Needed when no "at" is given

at : radiotools.atmosphere.models.Atmosphere
Atmospheric (density) profile model. Provides the density profile of the atmosphere in the typical 5-layer param.

Return : cherenkov Radius

"""
if at is None:
at = atm.Atmosphere(model=model)

d = at.get_distance_xmax_geometric(zenith, depth, obs_level)
return get_cherenkov_radius_model_from_distance(zenith, d, obs_level, n0, at.model)


def get_cherenkov_radius_model_from_height(zenith, height, obs_level, n0, model):
""" Calculates the radius of the (Cherenkov) cone with an apex at a given height above sea level on a
shower axis with a given zenith angle. The open angle of the cone equals the
Cherenkov angle for a value of the refractive index at this position.

Paramter:

zenith : double
Zenith angle (in radian) under which a shower is observed

height : double
Height above sea level (in m) of the apex, i.e., shower maximum of the observed shower

obs_level : double
Altitude (in meter) of the plane at which the shower is observed

n0 : double
Refractive index at sea level (!= obs_level)

model : int
Model index for the atmospheric (density) profile model.

Return : cherenkov Radius

"""

angle = get_cherenkov_angle_model(height, n0, model)
dmax = atm.get_distance_for_height_above_ground(
height - obs_level, zenith, observation_level=obs_level)
return cherenkov_radius(angle, dmax)


def get_cherenkov_radius_model_from_distance(zenith, d, obs_level, n0, model):
""" Calculates the radius of the (Cherenkov) cone with an apex at a given distance from ground
along the shower axis with a given zenith angle. The open angle of the cone equals the
Cherenkov angle for a value of the refractive index at this position.

Paramter:

zenith : double
Zenith angle (in radian) under which a shower is observed

d : double
Distance from ground to the apex, i.e., shower maximum of the observed shower along the shower axis (in m)

obs_level : double
Altitude (in meter) of the plane at which the shower is observed

n0 : double
Refractive index at sea level (!= obs_level)

model : int
Model index for the atmospheric (density) profile model.

Return : cherenkov Radius

"""
height = atm.get_height_above_ground(
d, zenith, observation_level=obs_level) + obs_level
angle = get_cherenkov_angle_model(height, n0, model)
return cherenkov_radius(angle, d)


def get_cherenkov_angle_model(height, n0, model):
""" Return cherenkov angle for given height above sea level,
refractive index at sea level and atmospheric model.

Paramter:

height : double
Height above sea level (in m)

n0 : double
Refractive index at sea level (!= obs_level)

model : int
Model index for the atmospheric (density) profile model.

Return : cherenkov angle

"""
n = atm.get_n(height, n0=n0, model=model)
return cherenkov_angle_model(n)


def cherenkov_angle_model(n):
""" Return cherenkov angle for given refractive index.

Paramter:

n : double
Refractive index

Return : cherenkov angle

"""
return np.arccos(1 / n)


def cherenkov_radius(angle, d):
""" Return (cherenkov) radius

Paramters
---------

angle : double
(Opening) angle of the cone (in rad)

d : double
Heigth of the cone (typically called distance, in meter)

Returns
-------

radius : double
(Cherenkov) radius

"""
return np.tan(angle) * d


# old: cherenkov_angle_from_density_refractivity(rho, dxmax, n_asl, rho_0, ...)
# param of the cherenkov angle from star-shape simulations
# here cherenkov radius refers to radius of strongest emission
# is used to determine rmax in the RdIdealGrid simulations!
def cherenkov_angle_param(
height, dist, n0, model,
a=9.48990456e-01, b=4.48698860e+03,
c=1.43097665e+00, d=2.46630811e+06):

n = atm.get_n(height, n0=n0, model=model)
A = a - (b / dist) ** (c) - dist / d

return A * cherenkov_angle_model(n)
# # old param
# def cherenkov_angle_from_density(x, A=0.24905864, B=0.92165234):
# return np.deg2rad(A * np.log(x) + B)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that relevant to keep? I am not sure if that is worth keeping in here. You could also remove the "model" from all the function names?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my code I added model to the function names because I implemented the revent functions with the same name, I believe.

Anyway, I think it is a good idea to add them here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the "old" section is irrelevant and shouldn't be included. I missed it when copying the other functions.
I'll remove the model parts of the function names too, they seem unneccessary here.

18 changes: 16 additions & 2 deletions radiotools/atmosphere/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,20 @@
'b': 1e4 * np.array([1111.70, 1128.64, 1413.98, 587.688, 1]),
'c': 1e-2 * np.array([766099., 641716., 588082., 693300., 5430320300]),
'h': 1e3 * np.array([7.6, 22.0, 40.4, 100.])
},
# Lenghu
# n @ sea level: 1.000276484920489
40: {'a': 1e4 * np.array([-165.436862, -136.096417, -0.822638028, 0.000573230645, 0.01128292]),
'b': 1e4 * np.array([1197.31182, 1170.37829, 1225.83319, 1331.36795, 1]),
'c': 1e-2 * np.array([1050681.74, 1014055.01, 712892.522, 692298.059, 1.e9]),
'h': 1e3 * np.array([3.703, 9.570, 26.816, 100.])
},
# Dunhuang
# n @ sea level: 1.000273455776266
41: {'a': 1e4 * np.array([-213.042077, -116.247782, 0.00113274359, 0.000571786955, 0.01128292]),
'b': 1e4 * np.array([1258.61938, 1170.17578, 1228.95805, 1228.88998, 1]),
'c': 1e-2 * np.array([1065331.16, 949496.792, 696242.875, 969256.762, 1.e9]),
'h': 1e3 * np.array([3.689, 9.378, 26.299, 100.])
}
}

Expand Down Expand Up @@ -817,7 +831,7 @@ def ftmp(d, zenith, xmax):
x0 = get_distance_for_height_above_ground(self._get_vertical_height_flat(zenith[i], X[i]), zenith[i])

# finding root e.g., distance for given xmax (when difference is 0)
dxmax_geo = optimize.brentq(ftmp, -1e3, x0 + 1e4, xtol=1e-6, args=(zenith[i], X[i]))
dxmax_geo = optimize.brentq(ftmp, -1e3, x0 + 2e4, xtol=1e-6, args=(zenith[i], X[i]))

height[i] = get_height_above_ground(
dxmax_geo, zenith[i], observation_level=observation_level) + observation_level
Expand Down Expand Up @@ -845,7 +859,7 @@ def ftmp(d, zenith, xmax):
x0 = get_distance_for_height_above_ground(self._get_vertical_height_flat(zenith[i], X[i]), zenith[i])

# finding root e.g., distance for given xmax (when difference is 0)
dxmax_geo = optimize.brentq(ftmp, -1e3, x0 + 1e4, xtol=1e-6, args=(zenith[i], X[i]))
dxmax_geo = optimize.brentq(ftmp, -1e3, x0 + 2e4, xtol=1e-6, args=(zenith[i], X[i]))

height[i] = get_height_above_ground(
dxmax_geo, zenith[i], observation_level=observation_level) + observation_level
Expand Down
4 changes: 2 additions & 2 deletions radiotools/coordinatesystems.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

import numpy as np
import math
from numpy.linalg import linalg
import numpy.linalg as linalg
import copy
import sys

Expand Down Expand Up @@ -158,7 +158,7 @@ def transform_from_early_late(self, positions, core=None):

_, nY = positions.shape
if(nY != 3):
sys.exit("Illeal position given")
sys.exit("Illegal position given")
else:
result = []
for pos in positions:
Expand Down
Loading