Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # -*- coding: utf-8
- ########################################################################
- #############SCAN INVARIANTS VALUES FROM res FILES#######################
- ########################################################################
- #2012-03-06 - Ugol ellipsa added
- import os, glob
- import re
- season = 'winter'
- year1 = '2007'
- year2 = '2007'
- path = './rean_res/res/*-*'
- dirs = glob.glob(path)
- dirs.sort()
- propusk = 999.0
- # I1 for IFREMER
- i1_sat_file_path = './calc/calc_rean/i1/i1_ifr_' + season + '_' + year1 + '_' + year2
- i1_sat_file = open(i1_sat_file_path, 'w')
- # L1 L2 XI UST for IFREMER
- L1_sat_file_path = './calc/calc_rean/l1/l1_ifr_' + season + '_' + year1 + '_' + year2
- L1_sat_file = open(L1_sat_file_path, 'w')
- L2_sat_file_path = './calc/calc_rean/l2/l2_ifr_' + season + '_' + year1 + '_' + year2
- L2_sat_file = open(L2_sat_file_path, 'w')
- XI_sat_file_path = './calc/calc_rean/xi/xi_ifr_' + season + '_' + year1 + '_' + year2
- XI_sat_file = open(XI_sat_file_path, 'w')
- UST_sat_file_path = './calc/calc_rean/ust/ust_ifr_' + season + '_' + year1 + '_' + year2
- UST_sat_file = open(UST_sat_file_path, 'w')
- #Math. expectation, ALPHA, ugol_ellipsa IFREMER
- ME_sat_file_path = './calc/calc_rean/me/me_ifr_' + season + '_' + year1 + '_' + year2
- ME_sat_file = open(ME_sat_file_path, 'w')
- ALPHA_sat_file_path = './calc/calc_rean/alpha/alpha_ifr_' + season + '_' + year1 + '_' + year2
- ALPHA_sat_file = open(ALPHA_sat_file_path, 'w')
- ugol_ellipsa_sat_file_path = './calc/calc_rean/ugol_ellipsa/ugol_ellipsa_ifr_' + season + '_' + year1 + '_' + year2
- ugol_ellipsa_sat_file = open(ugol_ellipsa_sat_file_path, 'w')
- # I1 for TOPAZ
- i1_topaz_file_path = './calc/calc_rean/i1/i1_topaz_' + season + '_' + year1 + '_' + year2
- i1_topaz_file = open(i1_topaz_file_path, 'w')
- # L1 L2 XI UST for TOPAZ
- L1_topaz_file_path = './calc/calc_rean/l1/l1_topaz_' + season + '_' + year1 + '_' + year2
- L1_topaz_file = open(L1_topaz_file_path, 'w')
- L2_topaz_file_path = './calc/calc_rean/l2/l2_topaz_' + season + '_' + year1 + '_' + year2
- L2_topaz_file = open(L2_topaz_file_path, 'w')
- XI_topaz_file_path = './calc/calc_rean/xi/xi_topaz_' + season + '_' + year1 + '_' + year2
- XI_topaz_file = open(XI_topaz_file_path, 'w')
- UST_topaz_file_path = './calc/calc_rean/ust/ust_topaz_' + season + '_' + year1 + '_' + year2
- UST_topaz_file = open(UST_topaz_file_path, 'w')
- #Math. expectation,ALPHA, ugol ellipsa TOPAZ
- ME_topaz_file_path = './calc/calc_rean/me/me_topaz_' + season + '_' + year1 + '_' + year2
- ME_topaz_file = open(ME_topaz_file_path, 'w')
- ALPHA_topaz_file_path = './calc/calc_rean/alpha/alpha_topaz_' + season + '_' + year1 + '_' + year2
- ALPHA_topaz_file = open(ALPHA_topaz_file_path, 'w')
- ugol_ellipsa_topaz_file_path = './calc/calc_rean/ugol_ellipsa/ugol_ellipsa_topaz_' + season + '_' + year1 + '_' + year2
- ugol_ellipsa_topaz_file = open(ugol_ellipsa_topaz_file_path, 'w')
- for filename in dirs:
- print filename
- iFile = open(filename, 'r')
- lines = iFile.readlines()
- #Longitude and Latitude from file name
- temp = re.split(r"/", filename)
- lat_lon = temp[-1]
- temp = re.split(r"-", lat_lon)
- lat = temp[1]
- lon = temp[0]
- print "lat-> ", lat
- print "lon-> ", lon
- if (len(lines))>67:
- i1_line_ifr = lines[12]
- ugol_ellipsa_line_ifr = lines[10]
- #Ifremer
- ff=re.split(r"=?L1", i1_line_ifr)
- ff=re.split(r"=", ff[0])
- i1 = float(ff[1])
- print "I1 IFREMER -> ", i1
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(i1))
- #2File
- i1_sat_file.write(str2File)
- #L1 sat
- gg=re.split('=?L1=',i1_line_ifr)
- gg = re.split(r'L2',gg[1])
- L1 = float(gg[0])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(L1))
- L1_sat_file.write(str2File)
- #L2 sat
- gg=re.split('=?L2=',i1_line_ifr)
- gg=re.split('\xd5',gg[1])
- L2 = float(gg[0])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(L2))
- L2_sat_file.write(str2File)
- #ugol ellipsa sat
- gg=re.split(r'alfa=',ugol_ellipsa_line_ifr)
- ugol_ellipsa_sat = gg[-1]
- if int(ugol_ellipsa_sat)<0:
- ugol_ellipsa_sat = int(ugol_ellipsa_sat) + 180
- str2File = '%7.3f %7.3f %7d\n' % (float(lat), float(lon), int(ugol_ellipsa_sat))
- ugol_ellipsa_sat_file.write(str2File)
- #XI sat
- gg=re.split(r'\xd3',i1_line_ifr)
- gg=re.split(r'\xc8=',gg[0])
- XI = float(gg[-1])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(XI))
- XI_sat_file.write(str2File)
- #UST sat
- gg=re.split(r'\xd3',i1_line_ifr)
- gg=re.split(r'\xdc=',gg[1])
- UST = float(gg[1])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(UST))
- UST_sat_file.write(str2File)
- #Mathematical expectation SAT
- me_line_ifr = lines[7]
- gg=re.split(r'\xd0:',me_line_ifr)
- a=re.compile('[\w.]+')
- ME_sat = float(a.findall(gg[1])[0])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(ME_sat))
- ME_sat_file.write(str2File)
- ALPHA_sat = float(a.findall(gg[1])[1])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(ALPHA_sat))
- ALPHA_sat_file.write(str2File)
- print '\n IFREMER Math. expectation -> ' + str(ME_sat) + ' alpha -> ', str(ALPHA_sat) + '\n'
- i1_line_topaz = lines[22]
- ugol_ellipsa_line_topaz = lines[20]
- #TOPAZ
- ff=re.split(r"=?L1", i1_line_topaz)
- ff=re.split(r"=", ff[0])
- i1 = float(ff[1])
- print "I1 TOPAZ -> ", i1
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(i1))
- #2File
- i1_topaz_file.write(str2File)
- rr = re.split('\s',i1_line_topaz)
- #L1 TOPAZ
- gg=re.split('=?L1=',i1_line_topaz)
- gg = re.split(r'L2',gg[1])
- L1 = float(gg[0])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(L1))
- L1_topaz_file.write(str2File)
- #L2 TOPAZ
- gg=re.split('=?L2=',i1_line_topaz)
- gg=re.split('\xd5',gg[1])
- L2 = float(gg[0])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(L2))
- L2_topaz_file.write(str2File)
- #ugol ellipsa TOPAZ
- gg=re.split(r'alfa=',ugol_ellipsa_line_topaz)
- ugol_ellipsa_topaz = gg[-1]
- if int(ugol_ellipsa_topaz)<0:
- ugol_ellipsa_topaz = int(ugol_ellipsa_topaz) + 180
- str2File = '%7.3f %7.3f %7d\n' % (float(lat), float(lon), int(ugol_ellipsa_topaz))
- ugol_ellipsa_topaz_file.write(str2File)
- #XI TOPAZ
- gg=re.split(r'\xd3',i1_line_topaz)
- gg=re.split(r'\xc8=',gg[0])
- XI = float(gg[-1])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(XI))
- XI_topaz_file.write(str2File)
- #UST sat
- gg=re.split(r'\xd3',i1_line_topaz)
- gg=re.split(r'\xdc=',gg[1])
- UST = float(gg[1])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(UST))
- UST_topaz_file.write(str2File)
- #Mathematical expectation TOPAZ
- me_line_topaz = lines[17]
- gg=re.split(r'\xd0:',me_line_topaz)
- a=re.compile('[\w.]+')
- ME_topaz = float(a.findall(gg[1])[0])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(ME_topaz))
- ME_topaz_file.write(str2File)
- ALPHA_topaz = float(a.findall(gg[1])[1])
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), float(ALPHA_topaz))
- ALPHA_topaz_file.write(str2File)
- print '\n TOPAZ Math. expectation -> ' + str(ME_topaz) + ' alpha -> ', str(ALPHA_topaz) + '\n'
- else:
- str2File = '%7.3f %7.3f %7.1f\n' % (float(lat), float(lon), propusk)
- #Пока ничего не пишем (999)
- #i1_sat_file.write(str2File)
- #i1_topaz_file.write(str2File)
- i1_sat_file.close()
- i1_topaz_file.close()
- L1_topaz_file.close()
- L1_sat_file.close()
- L2_topaz_file.close()
- L2_sat_file.close()
- XI_topaz_file.close()
- XI_sat_file.close()
- UST_topaz_file.close()
- UST_sat_file.close()
- ME_topaz_file.close()
- ME_sat_file.close()
- ALPHA_topaz_file.close()
- ALPHA_sat_file.close()
- ugol_ellipsa_topaz_file.close()
- ugol_ellipsa_sat_file.close()
Advertisement
Add Comment
Please, Sign In to add comment