Changeset 1775 in lmdz_wrf for trunk


Ignore:
Timestamp:
Feb 13, 2018, 10:17:38 PM (7 years ago)
Author:
lfita
Message:

Fixing mess!!!

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/tools/generic_tools.py

    r1774 r1775  
    4949
    5050####### Content
     51# angle_DegMinSec: Function to transform an angle to Degrees Minutes Seconds
    5152# ASCII_LaTeX: Function to transform from an ASCII character to LaTeX codification
    5253# ASCII_to: Function to provide the equivalence text to a given lenguage omitting certain characters
     
    7374# DateTimeStr_date: Function to transform a string date-time ([YYYY][MM][DD][HH][MI][SS] format) to a date object
    7475# datetimeStr_datetime: Function to transform a string date-time ([YYYY]-[MM]-[DD]_[HH]:[MI]:[SS] format) to a date object
     76# DegMinSec_angle: Function to transform Degrees Minutes Seconds to an angle
    7577# dictionary_key: Function to provide the first key in a dictionay with a given value
    7678# dictionary_key_list: Function to provide the first key in a dictionary of lists with a given value
     
    1261112613    return values
    1261212614
     12615def angle_DegMinSec(angle):
     12616   """ Function to transform an angle to Degrees Minutes Seconds
     12617     angle= decimal angle to transform
     12618     >>> angle_DegMinSec(3.98765)
     12619     3 59 15.54
     12620     >>> angle_DegMinSec(-23.0025)
     12621     -23 0 9.0                         
     12622   """
     12623   fname = 'angle_DegMinSec'
     12624                                     
     12625   degv = int(abs(angle))
     12626   minv = int((abs(angle) - degv*1.)*60.)
     12627   secv = (abs(angle) - degv*1. - minv/60.)*3600.
     12628                                                 
     12629   if angle < 0.:
     12630       return -degv, minv, secv
     12631   else:
     12632       return degv, minv, secv
     12633
     12634def DegMinSec_angle(degv, minv, secv):
     12635   """ Function to transform Degrees Minutes Seconds to an angle
     12636     degv: value in degrees
     12637     minv: minutes of arc
     12638     secv: seconds of arc
     12639     >>> DegMinSec_angle(-23, 0, 9.0)
     12640     -23.0025
     12641   """
     12642   fname = 'DegMinSec_angle'
     12643                                     
     12644   angle = np.abs(degv) + np.abs(minv)/60. + np.abs(secv)/3600.
     12645                                                 
     12646   if degv < 0.:
     12647       return -angle
     12648   else:
     12649       return angle
     12650
     12651def xtrm_nx(vals, percen):
     12652    """ Function to provide the extreme (a percentage above min,max) of a series of values as:
     12653          max(abs(min(vals)), max(vals))*percen
     12654      vals: values to use
     12655      percen: percentage [%] above the min/max
     12656    >>> xtrm_nx(np.arange(10, dtype=np.float), 110.)
     12657
     12658    """
     12659    fname = 'xtrm_nx'
     12660
     12661    nv = np.abs(np.min(vals))
     12662    xv = np.max(vals)
     12663    xtrm = np.max([nv,xv])*percen/100.
     12664
     12665    return xtrm
     12666
    1261312667#quit()
    1261412668
Note: See TracChangeset for help on using the changeset viewer.