- Timestamp:
- Sep 9, 2016, 12:55:36 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1084 r1086 1682 1682 [colns]= ',' list of color names ('None' for automatic, single value for all the same) 1683 1683 [lines]= ',' list of style of lines ('None' for automatic, single value for all the same) 1684 [points]= ' ,' list of style of points ('None' for automatic, single value for all the same)1684 [points]= '@' list of style of points ('None' for automatic, single value for all the same) 1685 1685 [lwdths]= ',' list of withs of lines ('None' for automatic, single value for all the same) 1686 1686 [psizes]= ',' list of size of points ('None' for automatic, single value for all the same) … … 1710 1710 vartit = values.split(':')[4] 1711 1711 title = values.split(':')[5].replace('|',' ') 1712 locleg = values.split(':')[6]1712 locleg = int(values.split(':')[6]) 1713 1713 colns = gen.str_list(values.split(':')[7], ',') 1714 1714 lines = gen.str_list(values.split(':')[8], ',') 1715 points = gen.str_list(values.split(':')[9], ' ,')1715 points = gen.str_list(values.split(':')[9], '@') 1716 1716 lwdths = gen.str_list(values.split(':')[10], ',') 1717 1717 psizes = gen.str_list(values.split(':')[11], ',') … … 1839 1839 [collines]: ',' list of colors for the lines, None for automatic, single 1840 1840 value all the same 1841 [points]: ' ,' list of type of points for the lines, None for automatic, single1841 [points]: '@' list of type of points for the lines, None for automatic, single 1842 1842 value all the same 1843 1843 [linewidths]: ',' list of widths for the lines, None for automatic, single … … 1926 1926 points.append(points0) 1927 1927 else: 1928 points = points0.split(' ,')1928 points = points0.split('@') 1929 1929 elif points0 == 'None': 1930 1930 points = None … … 2034 2034 "' has any variable '", varname, "' !!" 2035 2035 quit(-1) 2036 if vdobj.units.find('month') != 1:2036 if vdobj.units.find('month') != -1: 2037 2037 print warnmsg 2038 print ' ' + fname + ": tran forming time units from 'months' to 'days'!!"2038 print ' ' + fname + ": transforming time units from 'months' to 'days'!!" 2039 2039 timevals0, tunits0 = gen.CFmonthU_daysU(vdobj[:], vdobj.units) 2040 2040 else: … … 2045 2045 if ifn > 0: 2046 2046 # Referring all times to the same reference time! 2047 reftvals = drw.coincident_CFtimes(timevals0, timeunit, tunits0)2047 reftvals = gen.coincident_CFtimes(timevals0, timeunit, tunits0) 2048 2048 else: 2049 2049 reftvals = timevals0 … … 3046 3046 print warnmsg 3047 3047 print ' ' + fname + ': different time units in the plot!!' 3048 newtimes = drw.coincident_CFtimes(otim[:], tunits, otim.getncattr('units'))3048 newtimes = gen.coincident_CFtimes(otim[:], tunits, otim.getncattr('units')) 3049 3049 else: 3050 3050 newtimes = otim[:] … … 4439 4439 4440 4440 # Time axis taking time units in line A as reference 4441 varvalsaxisB = drw.coincident_CFtimes(timevalsB, tunitsA, tunitsB)4441 varvalsaxisB = gen.coincident_CFtimes(timevalsB, tunitsA, tunitsB) 4442 4442 trangeB = [np.min(varvalsaxisB), np.max(varvalsaxisB)] 4443 4443 -
trunk/tools/drawing_tools.py
r1077 r1086 2634 2634 return boolv 2635 2635 2636 def coincident_CFtimes(tvalB, tunitA, tunitB):2637 """ Function to make coincident times for two different sets of CFtimes2638 tvalB= time values B2639 tunitA= time units times A to which we want to make coincidence2640 tunitB= time units times B2641 >>> coincident_CFtimes(np.arange(10),'seconds since 1949-12-01 00:00:00',2642 'hours since 1949-12-01 00:00:00')2643 [ 0. 3600. 7200. 10800. 14400. 18000. 21600. 25200. 28800. 32400.]2644 >>> coincident_CFtimes(np.arange(10),'seconds since 1949-12-01 00:00:00',2645 'hours since 1979-12-01 00:00:00')2646 [ 9.46684800e+08 9.46688400e+08 9.46692000e+08 9.46695600e+082647 9.46699200e+08 9.46702800e+08 9.46706400e+08 9.46710000e+082648 9.46713600e+08 9.46717200e+08]2649 """2650 import datetime as dt2651 fname = 'coincident_CFtimes'2652 2653 tunitA = tunitA.replace('_',' ')2654 tunitB = tunitB.replace('_',' ')2655 2656 trefA = tunitA.split(' ')[2] + ' ' + tunitA.split(' ')[3]2657 trefB = tunitB.split(' ')[2] + ' ' + tunitB.split(' ')[3]2658 tuA = tunitA.split(' ')[0]2659 tuB = tunitB.split(' ')[0]2660 2661 # if tuB == 'months':2662 # tvalB, tunitB = gen.CFmonthU_daysU(tvalB, tunitB)2663 # tuB = tunitB.split(' ')[0]2664 2665 if tuA != tuB:2666 if tuA == 'microseconds':2667 if tuB == 'microseconds':2668 tB = tvalB*1.2669 elif tuB == 'seconds':2670 tB = tvalB*10.e62671 elif tuB == 'minutes':2672 tB = tvalB*60.*10.e62673 elif tuB == 'hours':2674 tB = tvalB*3600.*10.e62675 elif tuB == 'days':2676 tB = tvalB*3600.*24.*10.e62677 else:2678 print errormsg2679 print ' ' + fname + ": combination of time untis: '" + tuA + \2680 "' & '" + tuB + "' not ready !!"2681 quit(-1)2682 elif tuA == 'seconds':2683 if tuB == 'microseconds':2684 tB = tvalB/10.e62685 elif tuB == 'seconds':2686 tB = tvalB*1.2687 elif tuB == 'minutes':2688 tB = tvalB*60.2689 elif tuB == 'hours':2690 tB = tvalB*3600.2691 elif tuB == 'days':2692 tB = tvalB*3600.*24.2693 else:2694 print errormsg2695 print ' ' + fname + ": combination of time untis: '" + tuA + \2696 "' & '" + tuB + "' not ready !!"2697 quit(-1)2698 elif tuA == 'minutes':2699 if tuB == 'microseconds':2700 tB = tvalB/(60.*10.e6)2701 elif tuB == 'seconds':2702 tB = tvalB/60.2703 elif tuB == 'minutes':2704 tB = tvalB*1.2705 elif tuB == 'hours':2706 tB = tvalB*60.2707 elif tuB == 'days':2708 tB = tvalB*60.*24.2709 else:2710 print errormsg2711 print ' ' + fname + ": combination of time untis: '" + tuA + \2712 "' & '" + tuB + "' not ready !!"2713 quit(-1)2714 elif tuA == 'hours':2715 if tuB == 'microseconds':2716 tB = tvalB/(3600.*10.e6)2717 elif tuB == 'seconds':2718 tB = tvalB/3600.2719 elif tuB == 'minutes':2720 tB = tvalB/60.2721 elif tuB == 'hours':2722 tB = tvalB*1.2723 elif tuB == 'days':2724 tB = tvalB*24.2725 else:2726 print errormsg2727 print ' ' + fname + ": combination of time untis: '" + tuA + \2728 "' & '" + tuB + "' not ready !!"2729 quit(-1)2730 elif tuA == 'days':2731 if tuB == 'microseconds':2732 tB = tvalB/(24.*3600.*10.e6)2733 elif tuB == 'seconds':2734 tB = tvalB/(24.*3600.)2735 elif tuB == 'minutes':2736 tB = tvalB/(24.*60.)2737 elif tuB == 'hours':2738 tB = tvalB/24.2739 elif tuB == 'days':2740 tB = tvalB*1.2741 else:2742 print errormsg2743 print ' ' + fname + ": combination of time untis: '" + tuA + \2744 "' & '" + tuB + "' not ready !!"2745 quit(-1)2746 else:2747 print errormsg2748 print ' ' + fname + ": time untis: '" + tuA + "' not ready !!"2749 quit(-1)2750 else:2751 tB = tvalB*1.2752 2753 if trefA != trefB:2754 trefTA = dt.datetime.strptime(trefA, '%Y-%m-%d %H:%M:%S')2755 trefTB = dt.datetime.strptime(trefB, '%Y-%m-%d %H:%M:%S')2756 2757 difft = trefTB - trefTA2758 diffv = difft.days*24.*3600.*10.e6 + difft.seconds*10.e6 + difft.microseconds2759 print ' ' + fname + ': different reference refA:',trefTA,'refB',trefTB2760 print ' difference:',difft,':',diffv,'microseconds'2761 2762 if tuA == 'microseconds':2763 tB = tB + diffv2764 elif tuA == 'seconds':2765 tB = tB + diffv/10.e62766 elif tuA == 'minutes':2767 tB = tB + diffv/(60.*10.e6)2768 elif tuA == 'hours':2769 tB = tB + diffv/(3600.*10.e6)2770 elif tuA == 'days':2771 tB = tB + diffv/(24.*3600.*10.e6)2772 else:2773 print errormsg2774 print ' ' + fname + ": time untis: '" + tuA + "' not ready !!"2775 quit(-1)2776 2777 return tB2778 2779 2636 ####### ###### ##### #### ### ## # 2780 2637 … … 5799 5656 print ' ' + fname + ': number of provided colors:', Ncols, \ 5800 5657 'and required:', Nstyles,'differ !!' 5658 print ' provided:', colors 5801 5659 quit(-1) 5802 5660 usecolors = colors … … 5819 5677 print ' ' + fname + ': number of provided lines:', Nklns, \ 5820 5678 'and required:', Nstyles,'differ !!' 5679 print ' provided:', lines 5821 5680 quit(-1) 5822 5681 uselines = lines … … 5839 5698 print ' ' + fname + ': number of provided points:', Nkpts, \ 5840 5699 'and required:', Nstyles,'differ !!' 5700 print ' provided:', points 5841 5701 quit(-1) 5842 5702 usepoints = points … … 5859 5719 print ' ' + fname + ': number of provided line widthss:', Nwlns, \ 5860 5720 'and required:', Nstyles, 'differ !!' 5721 print ' provided:', lwidths 5861 5722 quit(-1) 5862 5723 usewlines = lwidths … … 5879 5740 print ' ' + fname + ': number of provided point sizes:', Nspts, \ 5880 5741 'and required:', Nstyles, 'differ !!' 5742 print ' provided:', psizes 5881 5743 quit(-1) 5882 5744 usespoints = psizes -
trunk/tools/generic_tools.py
r1076 r1086 33 33 # chainSnum_levnext: Function to provide the next value for a given level from a chainStrnum hirerarchy of numbers 34 34 # chainSnum_num: Function to pass a `ChainStrNum' string to a number 35 # coincident_CFtimes: Function to make coincident times for two different sets of CFtimes 35 36 # coldec_hex: Function to pas a decimal ([r,g,b]; [0.,1.]) color to hexadecimal (#[RR][GG][BB], 00-64, 0A-FF) 36 37 # colhex_dec: Function to pas a hexadecimal (#[RR][GG][BB]; 00-64, 0A-FF) color to decimal ([0.,1.]) … … 8451 8452 return diffs, Bdiff 8452 8453 8454 8455 def coincident_CFtimes(tvalB, tunitA, tunitB): 8456 """ Function to make coincident times for two different sets of CFtimes 8457 tvalB= time values B 8458 tunitA= time units times A to which we want to make coincidence 8459 tunitB= time units times B 8460 >>> coincident_CFtimes(np.arange(10),'seconds since 1949-12-01 00:00:00', 8461 'hours since 1949-12-01 00:00:00') 8462 [ 0. 3600. 7200. 10800. 14400. 18000. 21600. 25200. 28800. 32400.] 8463 >>> coincident_CFtimes(np.arange(10),'seconds since 1949-12-01 00:00:00', 8464 'hours since 1979-12-01 00:00:00') 8465 [ 9.46684800e+08 9.46688400e+08 9.46692000e+08 9.46695600e+08 8466 9.46699200e+08 9.46702800e+08 9.46706400e+08 9.46710000e+08 8467 9.46713600e+08 9.46717200e+08] 8468 """ 8469 import datetime as dt 8470 fname = 'coincident_CFtimes' 8471 8472 tunitA = tunitA.replace('_',' ') 8473 tunitB = tunitB.replace('_',' ') 8474 8475 trefA = tunitA.split(' ')[2] + ' ' + tunitA.split(' ')[3] 8476 trefB = tunitB.split(' ')[2] + ' ' + tunitB.split(' ')[3] 8477 tuA = tunitA.split(' ')[0] 8478 tuB = tunitB.split(' ')[0] 8479 8480 # if tuB == 'months': 8481 # tvalB, tunitB = gen.CFmonthU_daysU(tvalB, tunitB) 8482 # tuB = tunitB.split(' ')[0] 8483 8484 if tuA != tuB: 8485 if tuA == 'microseconds': 8486 if tuB == 'microseconds': 8487 tB = tvalB*1. 8488 elif tuB == 'seconds': 8489 tB = tvalB*10.e6 8490 elif tuB == 'minutes': 8491 tB = tvalB*60.*10.e6 8492 elif tuB == 'hours': 8493 tB = tvalB*3600.*10.e6 8494 elif tuB == 'days': 8495 tB = tvalB*3600.*24.*10.e6 8496 else: 8497 print errormsg 8498 print ' ' + fname + ": combination of time untis: '" + tuA + \ 8499 "' & '" + tuB + "' not ready !!" 8500 quit(-1) 8501 elif tuA == 'seconds': 8502 if tuB == 'microseconds': 8503 tB = tvalB/10.e6 8504 elif tuB == 'seconds': 8505 tB = tvalB*1. 8506 elif tuB == 'minutes': 8507 tB = tvalB*60. 8508 elif tuB == 'hours': 8509 tB = tvalB*3600. 8510 elif tuB == 'days': 8511 tB = tvalB*3600.*24. 8512 else: 8513 print errormsg 8514 print ' ' + fname + ": combination of time untis: '" + tuA + \ 8515 "' & '" + tuB + "' not ready !!" 8516 quit(-1) 8517 elif tuA == 'minutes': 8518 if tuB == 'microseconds': 8519 tB = tvalB/(60.*10.e6) 8520 elif tuB == 'seconds': 8521 tB = tvalB/60. 8522 elif tuB == 'minutes': 8523 tB = tvalB*1. 8524 elif tuB == 'hours': 8525 tB = tvalB*60. 8526 elif tuB == 'days': 8527 tB = tvalB*60.*24. 8528 else: 8529 print errormsg 8530 print ' ' + fname + ": combination of time untis: '" + tuA + \ 8531 "' & '" + tuB + "' not ready !!" 8532 quit(-1) 8533 elif tuA == 'hours': 8534 if tuB == 'microseconds': 8535 tB = tvalB/(3600.*10.e6) 8536 elif tuB == 'seconds': 8537 tB = tvalB/3600. 8538 elif tuB == 'minutes': 8539 tB = tvalB/60. 8540 elif tuB == 'hours': 8541 tB = tvalB*1. 8542 elif tuB == 'days': 8543 tB = tvalB*24. 8544 else: 8545 print errormsg 8546 print ' ' + fname + ": combination of time untis: '" + tuA + \ 8547 "' & '" + tuB + "' not ready !!" 8548 quit(-1) 8549 elif tuA == 'days': 8550 if tuB == 'microseconds': 8551 tB = tvalB/(24.*3600.*10.e6) 8552 elif tuB == 'seconds': 8553 tB = tvalB/(24.*3600.) 8554 elif tuB == 'minutes': 8555 tB = tvalB/(24.*60.) 8556 elif tuB == 'hours': 8557 tB = tvalB/24. 8558 elif tuB == 'days': 8559 tB = tvalB*1. 8560 else: 8561 print errormsg 8562 print ' ' + fname + ": combination of time untis: '" + tuA + \ 8563 "' & '" + tuB + "' not ready !!" 8564 quit(-1) 8565 else: 8566 print errormsg 8567 print ' ' + fname + ": time untis: '" + tuA + "' not ready !!" 8568 quit(-1) 8569 else: 8570 tB = tvalB*1. 8571 8572 if trefA != trefB: 8573 trefTA = dt.datetime.strptime(trefA, '%Y-%m-%d %H:%M:%S') 8574 trefTB = dt.datetime.strptime(trefB, '%Y-%m-%d %H:%M:%S') 8575 8576 difft = trefTB - trefTA 8577 diffv = difft.days*24.*3600.*10.e6 + difft.seconds*10.e6 + difft.microseconds 8578 print ' ' + fname + ': different reference refA:',trefTA,'refB',trefTB 8579 print ' difference:',difft,':',diffv,'microseconds' 8580 8581 if tuA == 'microseconds': 8582 tB = tB + diffv 8583 elif tuA == 'seconds': 8584 tB = tB + diffv/10.e6 8585 elif tuA == 'minutes': 8586 tB = tB + diffv/(60.*10.e6) 8587 elif tuA == 'hours': 8588 tB = tB + diffv/(3600.*10.e6) 8589 elif tuA == 'days': 8590 tB = tB + diffv/(24.*3600.*10.e6) 8591 else: 8592 print errormsg 8593 print ' ' + fname + ": time untis: '" + tuA + "' not ready !!" 8594 quit(-1) 8595 8596 return tB 8597 8453 8598 #quit() 8454 8599
Note: See TracChangeset
for help on using the changeset viewer.