I have created a function that returns both positive and negative angles of float type. What I want to do is to create an "if" statement inside the function where I will be able to add 360 degrees to every negative value while the positive one will stay as they are. Practically the function will return an array where to all negative value we will have added 360.
Also bear in mind that 'za' variable is an array input from another function. I will give you a part of the code to have it as a reference as well as the result after executing the azimuth_zenith(za, lat, dec) function:
NPTSRC = 60
lat=-30.7215
dec = np.linspace(0, 90, NPTSRC)
# Azimuth calculation as a function of zenith angle
def azimuth_zenith(za, lat, dec):
return np.arccos(np.sin(dec) - np.sin(za)*np.sin(lat))/(np.cos(za)*np.cos(lat))*180/np.pi
<ipython-input-33-7f401ef5875d>:3: RuntimeWarning: invalid value encountered in arccos
return np.arccos(np.sin(dec) - np.sin(za)*np.sin(lat))/(np.cos(za)*np.cos(lat))*180/np.pi
array([ 145.85139281, nan, 157.21910259, nan,
163.433071 , nan, 516.81605872, nan,
-138.24088045, 349.94353713, -332.53694854, nan,
nan, nan, nan, nan,
nan, 44.93813245, -74.67242873, 230.00752261,
175.72954699, nan, nan, nan,
nan, 437.90927583, nan, -1208.3420051 ,
nan, 86.67738103, nan, -156.84769435,
nan, -504.64406287, nan, 295.70813096,
nan, 152.11497124, nan, -124.51901853,
nan, 130.40918907, -117.47838581, 60.8683529 ,
nan, -217.09978828, nan, 117.3825354 ,
nan, nan, nan, nan,
nan, nan, -235.95740481, nan,
186.56132365, nan, -100.13272745, nan])
Aucun commentaire:
Enregistrer un commentaire