예제 #1
0
def pvl_relativeairmass(**kwargs):
    Expect={'z': ('array','num','x<=90','x>=0'),
        'model': ('default','default=kastenyoung1989')}

    var=pvt.Parse(kwargs,Expect)
    
    if ('kastenyoung1989') == var.model.lower():
        AM=1.0 / (np.cos(np.radians(var.z)) + 0.50572*(((6.07995 + (90 - var.z)) ** - 1.6364)))
    else:
        if ('kasten1966') == var.model.lower():
            AM=1.0 / (np.cos(np.radians(var.z)) + 0.15*((93.885 - var.z) ** - 1.253))
        else:
            if ('simple') == var.model.lower():
                AM=np.sec(np.radians(var.z))
            else:
                if ('pickering2002') == var.model.lower():
                    AM=1.0 / (np.sin(np.radians(90 - var.z + 244.0 / (165 + 47.0 * (90 - var.z) ** 1.1))))
                else:
                    if ('youngirvine1967') == var.model.lower():
                        AM=1.0 / np.cos(np.radians(var.z))*((1 - 0.0012*((((np.sec(np.radians(var.z)) ** 2) - 1)))))
                    else:
                        if ('young1994') == var.model.lower():
                            AM=(1.002432*((np.cos(np.radians(var.z))) ** 2) + 0.148386*(np.cos(np.radians(var.z))) + 0.0096467) / (np.cos(np.radians(var.z)) ** 3 + 0.149864*(np.cos(np.radians(var.z)) ** 2) + 0.0102963*(np.cos(np.radians(var.z))) + 0.000303978)
                        else:
                            if ('gueymard1993') == var.model.lower():
                                AM=1.0 / (np.cos(np.radians(var.z)) + 0.00176759*(var.z)*((94.37515 - var.z) ** - 1.21563))
                            else:
                                print(var.model + " is not a valid model type for relative airmass. The 'kastenyoung1989' model was used.")
                                AM=1.0 / (np.cos(np.radians(var.z)) + 0.50572*(((6.07995 + (90 - var.z)) ** - 1.6364)))
    return AM
예제 #2
0
def pvl_relativeairmass(z, model="kastenyoung1989"):
    """
  Gives the relative (not pressure-corrected) airmass

    Gives the airmass at sea-level when given a sun zenith angle, z (in 
    degrees). 
    The "model" variable allows selection of different airmass models
    (described below). "model" must be a valid string. If "model" is not 
    included or is not valid, the default model is 'kastenyoung1989'.

  Parameters
  ----------

  z : float or DataFrame 

      Zenith angle of the sun.  Note that some models use the apparent (refraction corrected)
      zenith angle, and some models use the true (not refraction-corrected)
      zenith angle. See model descriptions to determine which type of zenith
      angle is required.
      
  model : String 
      Avaiable models include the following:

         * 'simple' - secant(apparent zenith angle) - Note that this gives -inf at zenith=90
         * 'kasten1966' - See reference [1] - requires apparent sun zenith
         * 'youngirvine1967' - See reference [2] - requires true sun zenith
         * 'kastenyoung1989' - See reference [3] - requires apparent sun zenith
         * 'gueymard1993' - See reference [4] - requires apparent sun zenith
         * 'young1994' - See reference [5] - requries true sun zenith
         * 'pickering2002' - See reference [6] - requires apparent sun zenith

  Returns
  -------
    AM : float or DataFrame 
            Relative airmass at sea level.  Will return NaN values for all zenith 
            angles greater than 90 degrees.

  References
  ----------

  [1] Fritz Kasten. "A New Table and Approximation Formula for the
  Relative Optical Air Mass". Technical Report 136, Hanover, N.H.: U.S.
  Army Material Command, CRREL.

  [2] A. T. Young and W. M. Irvine, "Multicolor Photoelectric Photometry
  of the Brighter Planets," The Astronomical Journal, vol. 72, 
  pp. 945-950, 1967.

  [3] Fritz Kasten and Andrew Young. "Revised optical air mass tables and
  approximation formula". Applied Optics 28:4735-4738

  [4] C. Gueymard, "Critical analysis and performance assessment of 
  clear sky solar irradiance models using theoretical and measured data,"
  Solar Energy, vol. 51, pp. 121-138, 1993.

  [5] A. T. Young, "AIR-MASS AND REFRACTION," Applied Optics, vol. 33, 
  pp. 1108-1110, Feb 1994.

  [6] Keith A. Pickering. "The Ancient Star Catalog". DIO 12:1, 20,

  See Also
  --------
  pvl_absoluteairmass
  pvl_ephemeris

  """
    Vars = locals()
    Expect = {"z": ("array", "num", "x<=90", "x>=0"), "model": ("default", "default=kastenyoung1989")}
    var = pvt.Parse(Vars, Expect)

    if ("kastenyoung1989") == var.model.lower():
        AM = 1.0 / (np.cos(np.radians(var.z)) + 0.50572 * (((6.07995 + (90 - var.z)) ** -1.6364)))
    else:
        if ("kasten1966") == var.model.lower():
            AM = 1.0 / (np.cos(np.radians(var.z)) + 0.15 * ((93.885 - var.z) ** -1.253))
        else:
            if ("simple") == var.model.lower():
                AM = np.sec(np.radians(var.z))
            else:
                if ("pickering2002") == var.model.lower():
                    AM = 1.0 / (np.sin(np.radians(90 - var.z + 244.0 / (165 + 47.0 * (90 - var.z) ** 1.1))))
                else:
                    if ("youngirvine1967") == var.model.lower():
                        AM = (
                            1.0
                            / np.cos(np.radians(var.z))
                            * ((1 - 0.0012 * ((((np.sec(np.radians(var.z)) ** 2) - 1)))))
                        )
                    else:
                        if ("young1994") == var.model.lower():
                            AM = (
                                1.002432 * ((np.cos(np.radians(var.z))) ** 2)
                                + 0.148386 * (np.cos(np.radians(var.z)))
                                + 0.0096467
                            ) / (
                                np.cos(np.radians(var.z)) ** 3
                                + 0.149864 * (np.cos(np.radians(var.z)) ** 2)
                                + 0.0102963 * (np.cos(np.radians(var.z)))
                                + 0.000303978
                            )
                        else:
                            if ("gueymard1993") == var.model.lower():
                                AM = 1.0 / (
                                    np.cos(np.radians(var.z)) + 0.00176759 * (var.z) * ((94.37515 - var.z) ** -1.21563)
                                )
                            else:
                                print(
                                    var.model
                                    + " is not a valid model type for relative airmass. The 'kastenyoung1989' model was used."
                                )
                                AM = 1.0 / (
                                    np.cos(np.radians(var.z)) + 0.50572 * (((6.07995 + (90 - var.z)) ** -1.6364))
                                )
    return AM
예제 #3
0
 def pdf(self, x):
     """This is your PDF"""
     return np.sqrt(np.sec(x**4))
       [False, False, False]])
>>> np.array_equal(arr,arr2)
False
>>> np.sqrt(arr)
array([[0.80598621, 1.08580105, 2.61644598],
       [1.20709347, 2.12958701, 2.9083711 ],
       [1.96245271, 2.39936202, 2.9939203 ]])
>>> np.sin(arr)
array([[ 0.60487889,  0.92421085,  0.53339084],
       [ 0.99354066, -0.98433263,  0.82270634],
       [-0.6515516 , -0.50229186,  0.44504024]])
>>> np.cos(arr2)
array([[ 0.54030231, -0.41614684, -0.9899925 ],
       [-0.65364362,  0.28366219,  0.96017029],
       [ 0.75390225, -0.14550003, -0.91113026]])
>>> np.sec(arr)
Traceback (most recent call last):
  File "<pyshell#92>", line 1, in <module>
    np.sec(arr)
AttributeError: module 'numpy' has no attribute 'sec'
>>> np.tan(arr)
array([[ 0.75959514,  2.42014405,  0.63058335],
       [ 8.75545783,  5.58260044, -1.44723779],
       [ 0.858882  , -0.58088694, -0.49696815]])
>>> np.cosec(arr2)
Traceback (most recent call last):
  File "<pyshell#94>", line 1, in <module>
    np.cosec(arr2)
AttributeError: module 'numpy' has no attribute 'cosec'
>>> np.cot(arr)
Traceback (most recent call last):
예제 #5
0
 def pdf(self, x):
     """This is your PDF"""
     return np.sqrt(np.sec(x ** 4))
예제 #6
0
def sec(x):
    return np.sec(x)
예제 #7
0
         x = np.arange(0, c * (np.pi), 0.1)
         y = np.tan(x)
         plt.plot(x, y)
         plt.show()
     elif b == "cosec":
         import matplotlib.pyplot as plt
         import numpy as np
         x = np.arange(0, c * (np.pi), 0.1)
         y = np.csc(x)
         plt.plot(x, y)
         plt.show()
     elif b == "sec":
         import matplotlib.pyplot as plt
         import numpy as np
         x = np.arange(0, c * (np.pi), 0.1)
         y = np.sec(x)
         plt.plot(x, y)
         plt.show()
     elif b == "cot":
         import matplotlib.pyplot as plt
         import numpy as np
         x = np.arange(0, c * (np.pi), 0.1)
         y = np.cot(x)
         plt.plot(x, y)
         plt.show()
     else:
         print("INVALID INPUT")
 elif d == "EXPONENTIAL":
     f = int(input("ENTER THE FIRST VALUE OF RANGE:"))
     g = int(input("ENTER THE LAST VALUE OF RANGE:"))
     e = 2.718281828
예제 #8
0
def pvl_relativeairmass(z,model='kastenyoung1989'):
  '''
  Gives the relative (not pressure-corrected) airmass

    Gives the airmass at sea-level when given a sun zenith angle, z (in 
    degrees). 
    The "model" variable allows selection of different airmass models
    (described below). "model" must be a valid string. If "model" is not 
    included or is not valid, the default model is 'kastenyoung1989'.

  Parameters
  ----------

  z : float or DataFrame 

      Zenith angle of the sun.  Note that some models use the apparent (refraction corrected)
      zenith angle, and some models use the true (not refraction-corrected)
      zenith angle. See model descriptions to determine which type of zenith
      angle is required.
      
  model : String 
      Avaiable models include the following:

         * 'simple' - secant(apparent zenith angle) - Note that this gives -inf at zenith=90
         * 'kasten1966' - See reference [1] - requires apparent sun zenith
         * 'youngirvine1967' - See reference [2] - requires true sun zenith
         * 'kastenyoung1989' - See reference [3] - requires apparent sun zenith
         * 'gueymard1993' - See reference [4] - requires apparent sun zenith
         * 'young1994' - See reference [5] - requries true sun zenith
         * 'pickering2002' - See reference [6] - requires apparent sun zenith

  Returns
  -------
    AM : float or DataFrame 
            Relative airmass at sea level.  Will return NaN values for all zenith 
            angles greater than 90 degrees.

  References
  ----------

  [1] Fritz Kasten. "A New Table and Approximation Formula for the
  Relative Optical Air Mass". Technical Report 136, Hanover, N.H.: U.S.
  Army Material Command, CRREL.

  [2] A. T. Young and W. M. Irvine, "Multicolor Photoelectric Photometry
  of the Brighter Planets," The Astronomical Journal, vol. 72, 
  pp. 945-950, 1967.

  [3] Fritz Kasten and Andrew Young. "Revised optical air mass tables and
  approximation formula". Applied Optics 28:4735-4738

  [4] C. Gueymard, "Critical analysis and performance assessment of 
  clear sky solar irradiance models using theoretical and measured data,"
  Solar Energy, vol. 51, pp. 121-138, 1993.

  [5] A. T. Young, "AIR-MASS AND REFRACTION," Applied Optics, vol. 33, 
  pp. 1108-1110, Feb 1994.

  [6] Keith A. Pickering. "The Ancient Star Catalog". DIO 12:1, 20,

  See Also
  --------
  pvl_absoluteairmass
  pvl_ephemeris

  '''
  Vars=locals()
  Expect={'z': ('array','num','x<=90','x>=0'),
      'model': ('default','default=kastenyoung1989')}
  var=pvt.Parse(Vars,Expect)

  if ('kastenyoung1989') == var.model.lower():
      AM=1.0 / (np.cos(np.radians(var.z)) + 0.50572*(((6.07995 + (90 - var.z)) ** - 1.6364)))
  else:
      if ('kasten1966') == var.model.lower():
          AM=1.0 / (np.cos(np.radians(var.z)) + 0.15*((93.885 - var.z) ** - 1.253))
      else:
          if ('simple') == var.model.lower():
              AM=np.sec(np.radians(var.z))
          else:
              if ('pickering2002') == var.model.lower():
                  AM=1.0 / (np.sin(np.radians(90 - var.z + 244.0 / (165 + 47.0 * (90 - var.z) ** 1.1))))
              else:
                  if ('youngirvine1967') == var.model.lower():
                      AM=1.0 / np.cos(np.radians(var.z))*((1 - 0.0012*((((np.sec(np.radians(var.z)) ** 2) - 1)))))
                  else:
                      if ('young1994') == var.model.lower():
                          AM=(1.002432*((np.cos(np.radians(var.z))) ** 2) + 0.148386*(np.cos(np.radians(var.z))) + 0.0096467) / (np.cos(np.radians(var.z)) ** 3 + 0.149864*(np.cos(np.radians(var.z)) ** 2) + 0.0102963*(np.cos(np.radians(var.z))) + 0.000303978)
                      else:
                          if ('gueymard1993') == var.model.lower():
                              AM=1.0 / (np.cos(np.radians(var.z)) + 0.00176759*(var.z)*((94.37515 - var.z) ** - 1.21563))
                          else:
                              print(var.model + " is not a valid model type for relative airmass. The 'kastenyoung1989' model was used.")
                              AM=1.0 / (np.cos(np.radians(var.z)) + 0.50572*(((6.07995 + (90 - var.z)) ** - 1.6364)))
  return AM
# program for Multivariable calculus, Question 42 on 11.1

def ptOnCircle(r, theta):
	return [r*np.cos(theta), r*np.sin(theta)]

a = 4
b = 2

np.sec = lambda x: 1.0 / np.cos(x)

# d = [-np.pi, -np.pi/2.5, -np.pi/2.75, -np.pi/3.0, -np.pi/3.2, -np.pi/3.5, -np.pi/4.0, 0, np.pi/4.0, np.pi/3.5, np.pi/3.2, np.pi/3.0, np.pi/2.75, np.pi/2.5, np.pi]
d = [np.pi/4.0, np.pi/3.5, np.pi/3.2, np.pi/3.0, np.pi/2.75, np.pi/2.5, np.pi/1.5]

	
x = [a*np.sec(d[i]) for i in range(len(d))]
y = [b*np.sin(d[i]) for i in range(len(d))]

pts_a = [ptOnCircle(a, d[i]) for i in range(len(d))] # line from origin
i = 0
for pt in pts_a:
	plt.plot([0,pt[0],x[i]], [0, pt[1],0])
	i=i+1

pts_b = [ptOnCircle(b, d[i]) for i in range(len(d))]
i = 0
for pt in pts_b:
	plt.plot([pt[0],x[i], x[i]], [pt[1],y[i],0], c='red')
	i=i+1

	
예제 #10
0
 def evaluate(self):
     return np.sec(self.operand[0].evaluate())