@@ -127,6 +127,7 @@ def __init__(self,lon0='14 38.717E',lat0='22 58.783S',speed=130.0,UTC_start=7.0,
127127 if profile :
128128 lon0 ,lat0 ,UTC_start = profile ['Start_lon' ],profile ['Start_lat' ],profile ['UTC_start' ]
129129 UTC_conversion ,alt0 ,name ,campaign = profile ['UTC_conversion' ],profile ['start_alt' ],profile ['Plane_name' ],profile ['Campaign' ]
130+ self .profile = profile
130131 self .__version__ = version
131132 self .comments = [' ' ]
132133 self .wpname = [' ' ]
@@ -165,6 +166,9 @@ def __init__(self,lon0='14 38.717E',lat0='22 58.783S',speed=130.0,UTC_start=7.0,
165166 self .campaign = campaign
166167 self .datestr_verified = datestr_verified
167168 self .platform , self .p_info ,use_file = self .get_platform_info (name ,platform_file )
169+ for k in profile :
170+ if k not in self .p_info :
171+ self .p_info [k ] = profile [k ]
168172 self .pilot_format = self .p_info .get ('pilot_format' ,'DD MM SS' )
169173 if use_file :
170174 print ('Using platform data for: {} from platform file: {}' .format (self .platform ,os .path .abspath (platform_file )))
@@ -1220,7 +1224,7 @@ def print_points_kml(self,folder,includepng=False):
12201224 except :
12211225 pnt .style .iconstyle .icon .href = get_curdir ()+ '//map_icons//number_{}.png' .format (self .WP [i ])
12221226 else :
1223- pnt .style .iconstyle .icon .href = 'http ://maps.google .com/mapfiles/kml/paddle/{}-lv .png' .format (self .WP [i ])
1227+ pnt .style .iconstyle .icon .href = 'https ://www.samueleleblanc .com/img/icons/{} .png' .format (self .WP [i ])
12241228 pnt .description = """WP=#%02f\n UTC[H]=%2.2f\n WPname=%s\n Local[H]=%2.2f\n CumDist[km]=%f\n speed[m/s]=%4.2f\n delayT[min]=%f\n SZA[deg]=%3.2f\n AZI[deg]=%3.2f\n Bearing[deg]=%3.2f\n ClimbT[min]=%f\n Comments:%s""" % (self .WP [i ],
12251229 self .utc [i ],self .wpname [i ],self .local [i ],self .cumdist [i ],
12261230 self .speed [i ],self .delayt [i ],self .sza [i ],
@@ -1516,15 +1520,24 @@ def save2xl_for_pilots(filename,ex_arr):
15161520 else :
15171521 sh = wb_pilot .sheets .add (name = a .name ,after = wb_pilot .sheets [wb_pilot .sheets .count - 1 ])
15181522 #wb_pilot.sheets(1).add(name=a.name)
1523+
15191524 xw .Range ('A1' ).value = '{name} - {daystr} - ' .format (name = a .name ,daystr = a .datestr )
15201525 xw .Range ('A1' ).font .bold = True
15211526 xw .Range ('A1' ).font .size = 24
1522- #for st in ['A','B','C','D','E','F','G']:
1523- xw .Range ('A1:G1' ).color = rgb_to_int (to_rgb (a .color ))
1524- #import ipdb; ipdb.set_trace()
1525- xw .Range ('A2' ).value = ['WP' ,'WP name' ,'Lat\n [+-90]' ,'Lon\n [+-180]' ,
1527+
1528+ if not a .p_info .get ('include_mag_heading' ,False ):
1529+ xw .Range ('A2' ).value = ['WP' ,'WP name' ,'Lat\n [+-90]' ,'Lon\n [+-180]' ,
15261530 'Altitude\n [kft]' ,'UTC\n [hh:mm]' ,'Comments' ]
1527- xw .Range ('A2:G2' ).font .bold = True
1531+ letter_range = ['A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' ]
1532+ last_rgs = 'G'
1533+ else :
1534+ xw .Range ('A2' ).value = ['WP' ,'WP name' ,'Lat\n [+-90]' ,'Lon\n [+-180]' ,
1535+ 'Altitude\n [kft]' ,'UTC\n [hh:mm]' ,'Mag Heading\n [deg]' ,'Comments' ]
1536+ letter_range = ['A' ,'B' ,'C' ,'D' ,'E' ,'F' ,'G' ,'H' ]
1537+ xw .Range ('G3:G%i' % (a .n + 2 )).number_format = '0.0'
1538+ last_rgs = 'H'
1539+ xw .Range ('A1:' + last_rgs + '1' ).color = rgb_to_int (to_rgb (a .color ))
1540+ xw .Range ('A2:' + last_rgs + '2' ).font .bold = True
15281541 #freeze_top_pane(wb_pilot)
15291542 xw .Range ('F3:F%i' % (a .n + 2 )).number_format = 'hh:mm'
15301543 xw .Range ('E3:E%i' % (a .n + 2 )).number_format = '0.00'
@@ -1545,12 +1558,17 @@ def save2xl_for_pilots(filename,ex_arr):
15451558 comment = 'delay: {:2.1f} min, {}' .format (a .delayt [i ],a .comments [i ])
15461559 else :
15471560 comment = a .comments [i ]
1548- xw .Range ('A{:d}' .format (i + 3 )).value = [a .WP [i ],a .wpname [i ],lat_f ,lon_f ,a .alt_kft [i ],a .utc [i ]/ 24.0 ,comment ]
1561+ if not a .p_info .get ('include_mag_heading' ,False ):
1562+ xw .Range ('A{:d}' .format (i + 3 )).value = [a .WP [i ],a .wpname [i ],lat_f ,lon_f ,a .alt_kft [i ],a .utc [i ]/ 24.0 ,comment ]
1563+ else :
1564+ mag_decl = a .p_info .get ('mag_declination' ,13.0 )
1565+ xw .Range ('A{:d}' .format (i + 3 )).value = [a .WP [i ],a .wpname [i ],lat_f ,lon_f ,a .alt_kft [i ],a .utc [i ]/ 24.0 ,(360.0 + a .bearing [i ]- mag_decl )% 360 ,comment ]
15491566 if i % 2 :
1550- for st in [ 'A' , 'B' , 'C' , 'D' , 'E' , 'F' , 'G' ] :
1567+ for st in letter_range :
15511568 xw .Range ('{}{:d}' .format (st ,i + 2 )).color = rgb_to_int (make_lighter (to_rgb (a .color )))
15521569 xw .Range ('A{:d}' .format (i + 5 )).value = 'One line waypoints for foreflight:'
15531570 xw .Range ('A{:d}' .format (i + 6 )).value = one_line_points (a )
1571+ sh .page_setup .print_area = '$A$1:$' + last_rgs + '$%i' % (a .n + 2 )
15541572 wb_pilot .save (filename )
15551573 try :
15561574 wb_pilot .close ()
@@ -1578,26 +1596,27 @@ def save2csv_for_FOREFLIGHT_UFP(filename,ex,foreflight_only=True,verbose=True):
15781596 """
15791597 if filename .endswith ('.csv' ):
15801598 filename = filename [:- 4 ]
1581- if verbose : print ('.. saving FOREFLIGHT csv to {}' .format (filename + '_' + ex .name + '_FOREFLIGHT.csv' ))
1582- f = open (filename + '_' + ex .name + '_FOREFLIGHT.csv' ,'w+' )
1583- f .write ('Waypoint,Description,LAT,LONG\n ' )
1584- ex .wpname = ex .get_waypoint_names (fmt = ex .p_info .get ('waypoint_format' ,'{x.name[0]}{x.datestr.split("-")[2]}{w:02d}' ))
1585- for i in range (ex .n ):
1586- if ex .wpname [i ] in ex .wpname [0 :i ]: continue
1599+ if 'foreflight' in ex .p_info .get ('preferred_file_format' ,['foreflight' ]):
1600+ if verbose : print ('.. saving FOREFLIGHT csv to {}' .format (filename + '_' + ex .name + '_FOREFLIGHT.csv' ))
1601+ f = open (filename + '_' + ex .name + '_FOREFLIGHT.csv' ,'w+' )
1602+ f .write ('Waypoint,Description,LAT,LONG\n ' )
1603+ ex .wpname = ex .get_waypoint_names (fmt = ex .p_info .get ('waypoint_format' ,'{x.name[0]}{x.datestr.split("-")[2]}{w:02d}' ))
1604+ for i in range (ex .n ):
1605+ if ex .wpname [i ] in ex .wpname [0 :i ]: continue
15871606
1588- comm = ex .comments [i ]
1589- if ex .comments [i ]:
1590- comm = ex .comments [i ].replace (',' , '' )
1591- f .write ("""%s,ALT=%3.2f kft %s ,%+2.12f,%+2.12f\n """ % (
1592- ex .wpname [i ],ex .alt_kft [i ],comm ,ex .lat [i ],ex .lon [i ]))
1593- f .close ()
1607+ comm = ex .comments [i ]
1608+ if ex .comments [i ]:
1609+ comm = ex .comments [i ].replace (',' , '' )
1610+ f .write ("""%s,ALT=%3.2f kft %s ,%+2.12f,%+2.12f\n """ % (
1611+ ex .wpname [i ],ex .alt_kft [i ],comm ,ex .lat [i ],ex .lon [i ]))
1612+ f .close ()
15941613
1595- if verbose : print ('.. saving FOREFLIGHT one liner to {}' .format (filename + '_' + ex .name + '_FOREFLIGHT_oneline.txt' ))
1596- fo = open (filename + '_' + ex .name + '_FOREFLIGHT_oneline.txt' ,'w+' )
1597- fo .write (one_line_points (ex ,wpnames = ex .wpname ))
1598- fo .close ()
1614+ if verbose : print ('.. saving FOREFLIGHT one liner to {}' .format (filename + '_' + ex .name + '_FOREFLIGHT_oneline.txt' ))
1615+ fo = open (filename + '_' + ex .name + '_FOREFLIGHT_oneline.txt' ,'w+' )
1616+ fo .write (one_line_points (ex ,wpnames = ex .wpname ))
1617+ fo .close ()
15991618
1600- if 'er2' in ex .platform :
1619+ if 'er2' in ex .p_info . get ( 'preferred_file_format' ,[ 'foreflight' ]):
16011620 if verbose : print ('.. saving ER2 csv to {}' .format (filename + '_' + ex .name + '.csv' ))
16021621 fe = open (filename + '_' + ex .name + '.csv' ,'w+' )
16031622 fe .write ('ID,Description,LAT,LONG,Altitude [kft],UTC [hh:mm],Comments\n ' )
@@ -1608,38 +1627,40 @@ def save2csv_for_FOREFLIGHT_UFP(filename,ex,foreflight_only=True,verbose=True):
16081627 w = ex .WP [i ]
16091628 x = ex
16101629 wp_str = eval ("f'{}'" .format (ex .p_info .get ('waypoint_format' ,'{x.name[0]}{x.datestr.split("-")[2]}{w:02d}' )))
1611- desc = ex .wpname [i ]
1630+ desc = '.' + ex .wpname [i ]
16121631 if wp_str in ex .wpname [i ]:
16131632 desc = '.' + wp_str [0 ]+ wp_str [3 :5 ]
16141633 fe .write ("""%2.0f,%s,%+2.12f,%+2.12f,%3.2f,%2.0f:%02.0f,%s\n """ % (
16151634 ex .WP [i ],desc ,ex .lat [i ],ex .lon [i ],ex .alt_kft [i ],np .floor (ex .utc [i ]),(ex .utc [i ]- np .floor (ex .utc [i ]))* 60.0 ,comm ))
16161635 fe .close ()
16171636 return #no need to print out the rest
16181637
1619- if verbose : print ('.. saving UFP csv to {}' .format (filename + '_' + ex .name + '_UFP.csv' ))
1620- fu = open (filename + '_' + ex .name + '_UFP.csv' ,'w+' )
1621- fu .write ('Waypoint,LAT,LONG,Description\n ' )
1622- for i in range (ex .n ):
1623- if ex .wpname [i ] in ex .wpname [0 :i ]: continue
1624- comm = ex .comments [i ]
1625- if ex .comments [i ]:
1626- comm = ex .comments [i ].replace (',' , '' )
1627- fu .write ("""%s,%+2.12f,%+2.12f,ALT=%3.2f kft %s\n """ % (
1628- ex .wpname [i ],ex .lat [i ],ex .lon [i ],ex .alt_kft [i ],comm ))
1629- fu .close ()
1638+ if 'ufp' in ex .p_info .get ('preferred_file_format' ,['foreflight' ]):
1639+ if verbose : print ('.. saving UFP csv to {}' .format (filename + '_' + ex .name + '_UFP.csv' ))
1640+ fu = open (filename + '_' + ex .name + '_UFP.csv' ,'w+' )
1641+ fu .write ('Waypoint,LAT,LONG,Description\n ' )
1642+ for i in range (ex .n ):
1643+ if ex .wpname [i ] in ex .wpname [0 :i ]: continue
1644+ comm = ex .comments [i ]
1645+ if ex .comments [i ]:
1646+ comm = ex .comments [i ].replace (',' , '' )
1647+ fu .write ("""%s,%+2.12f,%+2.12f,ALT=%3.2f kft %s\n """ % (
1648+ ex .wpname [i ],ex .lat [i ],ex .lon [i ],ex .alt_kft [i ],comm ))
1649+ fu .close ()
16301650
1631- if verbose : print ('.. saving Honeywell csv to {}' .format (filename + '_' + ex .name + '_Honeywell.csv' ))
1632- fh = open (filename + '_' + ex .name + '_Honeywell.csv' ,'w+' )
1633- fh .write ('E,WPT,FIX,LAT,LON\n ' )
1634- for i in range (ex .n ):
1635- if ex .wpname [i ] in ex .wpname [0 :i ]: continue
1636- lat_str ,lon_str = format_lat_lon (ex .lat [i ],ex .lon [i ],format = 'NDDD MM.SS' )
1637- comm = ex .comments [i ]
1638- if ex .comments [i ]:
1639- comm = ex .comments [i ].replace (',' , '' )
1640- fh .write ("""x,%s,ALT=%3.2f kft %s,%s,%s\n """ % (
1641- ex .wpname [i ],ex .alt_kft [i ],comm ,lat_str ,lon_str ))
1642- fh .close ()
1651+ if 'honeywell' in ex .p_info .get ('preferred_file_format' ,['foreflight' ]):
1652+ if verbose : print ('.. saving Honeywell csv to {}' .format (filename + '_' + ex .name + '_Honeywell.csv' ))
1653+ fh = open (filename + '_' + ex .name + '_Honeywell.csv' ,'w+' )
1654+ fh .write ('E,WPT,FIX,LAT,LON\n ' )
1655+ for i in range (ex .n ):
1656+ if ex .wpname [i ] in ex .wpname [0 :i ]: continue
1657+ lat_str ,lon_str = format_lat_lon (ex .lat [i ],ex .lon [i ],format = 'NDDD MM.SS' )
1658+ comm = ex .comments [i ]
1659+ if ex .comments [i ]:
1660+ comm = ex .comments [i ].replace (',' , '' )
1661+ fh .write ("""x,%s,ALT=%3.2f kft %s,%s,%s\n """ % (
1662+ ex .wpname [i ],ex .alt_kft [i ],comm ,lat_str ,lon_str ))
1663+ fh .close ()
16431664
16441665
16451666
0 commit comments