Changeset 2811 in lmdz_wrf for trunk/tools
- Timestamp:
- Apr 8, 2020, 10:30:47 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/generic_tools.py
r2810 r2811 14112 14112 fname = 'truncate' 14113 14113 14114 multiplier = 10. ** decimals 14114 dec = decimals + 1 14115 multiplier = 10. ** dec 14115 14116 tfv = int(fv * multiplier) / multiplier 14116 14117 14117 return int(fv * multiplier) / multiplier 14118 # decimals section 14119 decsec = int(fv*multiplier-int(fv)*multiplier) 14120 14121 # last decimal 14122 if decsec != 0.: 14123 lastdecsec = int((decsec/10. - int(decsec/10.))*10) 14124 if lastdecsec > 5.: 14125 decsec = decsec + 1 14126 fv = int(fv) + decsec/multiplier 14127 14128 dec = decimals 14129 multiplier = 10. ** dec 14130 tfv = int(fv * multiplier) / multiplier 14131 14132 return tfv 14118 14133 14119 14134 def angle_DegMinSec(angle): … … 14129 14144 degv = int(abs(angle)) 14130 14145 minv = int((abs(angle) - degv*1.)*60.) 14131 secv = (abs(angle) - degv*1. - minv/60.)*3600. 14132 14146 secv = truncate((abs(angle) - degv*1. - minv/60.)*3600., 7) 14133 14147 if secv < 1.e-8: secv = 0. 14134 14148
Note: See TracChangeset
for help on using the changeset viewer.