|
1 | NO CONTENT: new file 100644 |
@@ -0,0 +1,1 | |||
|
1 | from jroutils_ftp import * No newline at end of file |
@@ -0,0 +1,348 | |||
|
1 | ''' | |
|
2 | @author: Daniel Suarez | |
|
3 | ''' | |
|
4 | import os | |
|
5 | import glob | |
|
6 | import ftplib | |
|
7 | from model.proc.jroproc_base import ProcessingUnit, Operation | |
|
8 | ||
|
9 | class FTP(): | |
|
10 | """ | |
|
11 | Ftp is a public class used to define custom File Transfer Protocol from "ftplib" python module | |
|
12 | ||
|
13 | Non-standard Python modules used: None | |
|
14 | ||
|
15 | Written by "Daniel Suarez":mailto:daniel.suarez@jro.igp.gob.pe Oct. 26, 2010 | |
|
16 | """ | |
|
17 | ||
|
18 | def __init__(self,server = None, username=None, password=None, remotefolder=None): | |
|
19 | """ | |
|
20 | This method is used to setting parameters for FTP and establishing connection to remote server | |
|
21 | ||
|
22 | Inputs: | |
|
23 | server - remote server IP Address | |
|
24 | ||
|
25 | username - remote server Username | |
|
26 | ||
|
27 | password - remote server password | |
|
28 | ||
|
29 | remotefolder - remote server current working directory | |
|
30 | ||
|
31 | Return: void | |
|
32 | ||
|
33 | Affects: | |
|
34 | self.status - in Error Case or Connection Failed this parameter is set to 1 else 0 | |
|
35 | ||
|
36 | self.folderList - sub-folder list of remote folder | |
|
37 | ||
|
38 | self.fileList - file list of remote folder | |
|
39 | ||
|
40 | ||
|
41 | """ | |
|
42 | ||
|
43 | if ((server == None) and (username==None) and (password==None) and (remotefolder==None)): | |
|
44 | server, username, password, remotefolder = self.parmsByDefault() | |
|
45 | ||
|
46 | self.server = server | |
|
47 | self.username = username | |
|
48 | self.password = password | |
|
49 | self.remotefolder = remotefolder | |
|
50 | self.file = None | |
|
51 | self.ftp = None | |
|
52 | self.status = 0 | |
|
53 | ||
|
54 | try: | |
|
55 | self.ftp = ftplib.FTP(self.server) | |
|
56 | self.ftp.login(self.username,self.password) | |
|
57 | self.ftp.cwd(self.remotefolder) | |
|
58 | # print 'Connect to FTP Server: Successfully' | |
|
59 | ||
|
60 | except ftplib.all_errors: | |
|
61 | print 'Error FTP Service' | |
|
62 | self.status = 1 | |
|
63 | return | |
|
64 | ||
|
65 | ||
|
66 | ||
|
67 | self.dirList = [] | |
|
68 | ||
|
69 | try: | |
|
70 | self.dirList = self.ftp.nlst() | |
|
71 | ||
|
72 | except ftplib.error_perm, resp: | |
|
73 | if str(resp) == "550 No files found": | |
|
74 | print "no files in this directory" | |
|
75 | self.status = 1 | |
|
76 | return | |
|
77 | ||
|
78 | except ftplib.all_errors: | |
|
79 | print 'Error Displaying Dir-Files' | |
|
80 | self.status = 1 | |
|
81 | return | |
|
82 | ||
|
83 | self.fileList = [] | |
|
84 | self.folderList = [] | |
|
85 | #only for test | |
|
86 | for f in self.dirList: | |
|
87 | name, ext = os.path.splitext(f) | |
|
88 | if ext != '': | |
|
89 | self.fileList.append(f) | |
|
90 | # print 'filename: %s - size: %d'%(f,self.ftp.size(f)) | |
|
91 | ||
|
92 | def parmsByDefault(self): | |
|
93 | server = 'jro-app.igp.gob.pe' | |
|
94 | username = 'wmaster' | |
|
95 | password = 'mst2010vhf' | |
|
96 | remotefolder = '/home/wmaster/graficos' | |
|
97 | ||
|
98 | return server, username, password, remotefolder | |
|
99 | ||
|
100 | ||
|
101 | def mkd(self,dirname): | |
|
102 | """ | |
|
103 | mkd is used to make directory in remote server | |
|
104 | ||
|
105 | Input: | |
|
106 | dirname - directory name | |
|
107 | ||
|
108 | Return: | |
|
109 | 1 in error case else 0 | |
|
110 | """ | |
|
111 | try: | |
|
112 | self.ftp.mkd(dirname) | |
|
113 | except: | |
|
114 | print 'Error creating remote folder:%s'%dirname | |
|
115 | return 1 | |
|
116 | ||
|
117 | return 0 | |
|
118 | ||
|
119 | ||
|
120 | def delete(self,filename): | |
|
121 | """ | |
|
122 | delete is used to delete file in current working directory of remote server | |
|
123 | ||
|
124 | Input: | |
|
125 | filename - filename to delete in remote folder | |
|
126 | ||
|
127 | Return: | |
|
128 | 1 in error case else 0 | |
|
129 | """ | |
|
130 | ||
|
131 | try: | |
|
132 | self.ftp.delete(filename) | |
|
133 | except: | |
|
134 | print 'Error deleting remote file:%s'%filename | |
|
135 | return 1 | |
|
136 | ||
|
137 | return 0 | |
|
138 | ||
|
139 | def download(self,filename,localfolder): | |
|
140 | """ | |
|
141 | download is used to downloading file from remote folder into local folder | |
|
142 | ||
|
143 | Inputs: | |
|
144 | filename - filename to donwload | |
|
145 | ||
|
146 | localfolder - directory local to store filename | |
|
147 | ||
|
148 | Returns: | |
|
149 | self.status - 1 in error case else 0 | |
|
150 | """ | |
|
151 | ||
|
152 | self.status = 0 | |
|
153 | ||
|
154 | ||
|
155 | if not(filename in self.fileList): | |
|
156 | print 'filename:%s not exists'%filename | |
|
157 | self.status = 1 | |
|
158 | return self.status | |
|
159 | ||
|
160 | newfilename = os.path.join(localfolder,filename) | |
|
161 | ||
|
162 | self.file = open(newfilename, 'wb') | |
|
163 | ||
|
164 | try: | |
|
165 | print 'Download: ' + filename | |
|
166 | self.ftp.retrbinary('RETR ' + filename, self.__handleDownload) | |
|
167 | print 'Download Complete' | |
|
168 | except ftplib.all_errors: | |
|
169 | print 'Error Downloading ' + filename | |
|
170 | self.status = 1 | |
|
171 | return self.status | |
|
172 | ||
|
173 | self.file.close() | |
|
174 | ||
|
175 | return self.status | |
|
176 | ||
|
177 | ||
|
178 | def __handleDownload(self,block): | |
|
179 | """ | |
|
180 | __handleDownload is used to handle writing file | |
|
181 | """ | |
|
182 | self.file.write(block) | |
|
183 | ||
|
184 | ||
|
185 | def upload(self,filename,remotefolder=None): | |
|
186 | """ | |
|
187 | upload is used to uploading local file to remote directory | |
|
188 | ||
|
189 | Inputs: | |
|
190 | filename - full path name of local file to store in remote directory | |
|
191 | ||
|
192 | remotefolder - remote directory | |
|
193 | ||
|
194 | Returns: | |
|
195 | self.status - 1 in error case else 0 | |
|
196 | """ | |
|
197 | ||
|
198 | if remotefolder == None: | |
|
199 | remotefolder = self.remotefolder | |
|
200 | ||
|
201 | self.status = 0 | |
|
202 | ||
|
203 | try: | |
|
204 | self.ftp.cwd(remotefolder) | |
|
205 | ||
|
206 | self.file = open(filename, 'rb') | |
|
207 | ||
|
208 | (head, tail) = os.path.split(filename) | |
|
209 | ||
|
210 | command = "STOR " + tail | |
|
211 | ||
|
212 | print 'Uploading: ' + tail | |
|
213 | self.ftp.storbinary(command, self.file) | |
|
214 | print 'Upload Completed' | |
|
215 | ||
|
216 | except ftplib.all_errors: | |
|
217 | print 'Error Uploading ' + tail | |
|
218 | self.status = 1 | |
|
219 | return self.status | |
|
220 | ||
|
221 | self.file.close() | |
|
222 | ||
|
223 | #back to initial directory in __init__() | |
|
224 | self.ftp.cwd(self.remotefolder) | |
|
225 | ||
|
226 | return self.status | |
|
227 | ||
|
228 | ||
|
229 | def dir(self,remotefolder): | |
|
230 | """ | |
|
231 | dir is used to change working directory of remote server and get folder and file list | |
|
232 | ||
|
233 | Input: | |
|
234 | remotefolder - current working directory | |
|
235 | ||
|
236 | Affects: | |
|
237 | self.fileList - file list of working directory | |
|
238 | ||
|
239 | Return: | |
|
240 | infoList - list with filenames and size of file in bytes | |
|
241 | ||
|
242 | self.folderList - folder list | |
|
243 | """ | |
|
244 | ||
|
245 | self.remotefolder = remotefolder | |
|
246 | print 'Change to ' + self.remotefolder | |
|
247 | try: | |
|
248 | self.ftp.cwd(remotefolder) | |
|
249 | except ftplib.all_errors: | |
|
250 | print 'Error Change to ' + self.remotefolder | |
|
251 | infoList = None | |
|
252 | self.folderList = None | |
|
253 | return infoList,self.folderList | |
|
254 | ||
|
255 | self.dirList = [] | |
|
256 | ||
|
257 | try: | |
|
258 | self.dirList = self.ftp.nlst() | |
|
259 | ||
|
260 | except ftplib.error_perm, resp: | |
|
261 | if str(resp) == "550 No files found": | |
|
262 | print "no files in this directory" | |
|
263 | infoList = None | |
|
264 | self.folderList = None | |
|
265 | return infoList,self.folderList | |
|
266 | except ftplib.all_errors: | |
|
267 | print 'Error Displaying Dir-Files' | |
|
268 | infoList = None | |
|
269 | self.folderList = None | |
|
270 | return infoList,self.folderList | |
|
271 | ||
|
272 | infoList = [] | |
|
273 | self.fileList = [] | |
|
274 | self.folderList = [] | |
|
275 | for f in self.dirList: | |
|
276 | name,ext = os.path.splitext(f) | |
|
277 | if ext != '': | |
|
278 | self.fileList.append(f) | |
|
279 | value = (f,self.ftp.size(f)) | |
|
280 | infoList.append(value) | |
|
281 | ||
|
282 | if ext == '': | |
|
283 | self.folderList.append(f) | |
|
284 | ||
|
285 | return infoList,self.folderList | |
|
286 | ||
|
287 | ||
|
288 | def close(self): | |
|
289 | """ | |
|
290 | close is used to close and end FTP connection | |
|
291 | ||
|
292 | Inputs: None | |
|
293 | ||
|
294 | Return: void | |
|
295 | ||
|
296 | """ | |
|
297 | self.ftp.close() | |
|
298 | ||
|
299 | class SendByFTP(Operation): | |
|
300 | def __init__(self): | |
|
301 | self.status = 1 | |
|
302 | ||
|
303 | def error_print(self, ValueError): | |
|
304 | print ValueError, 'Error FTP' | |
|
305 | print "don't worry the program is running..." | |
|
306 | ||
|
307 | def connect(self, server, username, password, remotefolder): | |
|
308 | if not(self.status): | |
|
309 | return | |
|
310 | try: | |
|
311 | self.ftpObj = FTP(server, username, password, remotefolder) | |
|
312 | except: | |
|
313 | self.error_print(ValueError) | |
|
314 | self.status = 0 | |
|
315 | ||
|
316 | def put(self): | |
|
317 | if not(self.status): | |
|
318 | return | |
|
319 | ||
|
320 | try: | |
|
321 | for filename in self.filenameList: | |
|
322 | self.ftpObj.upload(filename) | |
|
323 | except: | |
|
324 | self.error_print(ValueError) | |
|
325 | self.status = 0 | |
|
326 | ||
|
327 | def close(self): | |
|
328 | if not(self.status): | |
|
329 | return | |
|
330 | ||
|
331 | self.ftpObj.close() | |
|
332 | ||
|
333 | def filterByExt(self, ext, localfolder): | |
|
334 | fnameList = glob.glob1(localfolder,ext) | |
|
335 | self.filenameList = [os.path.join(localfolder,x) for x in fnameList] | |
|
336 | ||
|
337 | if len(self.filenameList) == 0: | |
|
338 | self.status = 0 | |
|
339 | ||
|
340 | def run(self, dataOut, ext, localfolder, remotefolder, server, username, password): | |
|
341 | ||
|
342 | self.filterByExt(ext, localfolder) | |
|
343 | ||
|
344 | self.connect(server, username, password, remotefolder) | |
|
345 | ||
|
346 | self.put() | |
|
347 | ||
|
348 | self.close() |
@@ -2,3 +2,4 from model.data.jrodata import * | |||
|
2 | 2 | from model.io.jrodataIO import * |
|
3 | 3 | from model.proc.jroprocessing import * |
|
4 | 4 | from model.graphics.jroplot import * |
|
5 | from model.utils.jroutils import * No newline at end of file |
@@ -305,7 +305,8 class RadarControllerHeader(Header): | |||
|
305 | 305 | self.code[ic,ib] = temp[ib/32]%2 |
|
306 | 306 | temp[ib/32] = temp[ib/32]/2 |
|
307 | 307 | self.code = 2.0*self.code - 1.0 |
|
308 | ||
|
308 | self.code_size = int(numpy.ceil(self.nBaud/32.))*self.nCode*4 | |
|
309 | ||
|
309 | 310 | if self.line5Function == RCfunction.FLIP: |
|
310 | 311 | self.flip1 = numpy.fromfile(fp,'<u4',1) |
|
311 | 312 | |
@@ -313,10 +314,9 class RadarControllerHeader(Header): | |||
|
313 | 314 | self.flip2 = numpy.fromfile(fp,'<u4',1) |
|
314 | 315 | |
|
315 | 316 | endFp = self.size + startFp |
|
316 |
|
|
|
317 |
|
|
|
318 | # | |
|
319 | fp.seek(endFp) | |
|
317 | jumpFp = endFp - fp.tell() | |
|
318 | if jumpFp > 0: | |
|
319 | fp.seek(jumpFp) | |
|
320 | 320 | |
|
321 | 321 | except Exception, e: |
|
322 | 322 | print "RadarControllerHeader: " + e |
@@ -182,29 +182,22 class SpectraPlot(Figure): | |||
|
182 | 182 | |
|
183 | 183 | self.draw() |
|
184 | 184 | |
|
185 |
if |
|
|
186 | ||
|
185 | if figfile == None: | |
|
186 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
|
187 | figfile = self.getFilename(name = str_datetime) | |
|
188 | ||
|
189 | if figpath != '': | |
|
187 | 190 | self.counter_imagwr += 1 |
|
188 |
if (self.counter_imagwr |
|
|
189 | if figfile == None: | |
|
190 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
|
191 | figfile = self.getFilename(name = str_datetime) | |
|
192 | ||
|
191 | if (self.counter_imagwr>=wr_period): | |
|
192 | # store png plot to local folder | |
|
193 | 193 | self.saveFigure(figpath, figfile) |
|
194 | ||
|
195 | if ftp: | |
|
196 | #provisionalmente envia archivos en el formato de la web en tiempo real | |
|
197 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
198 | path = '%s%03d' %(self.PREFIX, self.id) | |
|
199 | ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
|
200 | self.saveFigure(figpath, ftp_file) | |
|
201 | ftp_filename = os.path.join(figpath,ftp_file) | |
|
202 | self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
|
203 | self.counter_imagwr = 0 | |
|
204 | ||
|
205 | ||
|
194 | # store png plot to FTP server according to RT-Web format | |
|
195 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
196 | ftp_filename = os.path.join(figpath, name) | |
|
197 | self.saveFigure(figpath, ftp_filename) | |
|
206 | 198 | self.counter_imagwr = 0 |
|
207 | 199 | |
|
200 | ||
|
208 | 201 | class CrossSpectraPlot(Figure): |
|
209 | 202 | |
|
210 | 203 | isConfig = None |
@@ -595,55 +588,27 class RTIPlot(Figure): | |||
|
595 | 588 | |
|
596 | 589 | self.draw() |
|
597 | 590 | |
|
598 | # if lastone: | |
|
599 | # if dataOut.blocknow >= dataOut.last_block: | |
|
600 | # if figfile == None: | |
|
601 | # figfile = self.getFilename(name = self.name) | |
|
602 | # self.saveFigure(figpath, figfile) | |
|
603 | # | |
|
604 | # if (save and not(lastone)): | |
|
605 | # | |
|
606 | # self.counter_imagwr += 1 | |
|
607 | # if (self.counter_imagwr==wr_period): | |
|
608 | # if figfile == None: | |
|
609 | # figfile = self.getFilename(name = self.name) | |
|
610 | # self.saveFigure(figpath, figfile) | |
|
611 | # | |
|
612 | # if ftp: | |
|
613 | # #provisionalmente envia archivos en el formato de la web en tiempo real | |
|
614 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
615 | # path = '%s%03d' %(self.PREFIX, self.id) | |
|
616 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
|
617 | # self.saveFigure(figpath, ftp_file) | |
|
618 | # ftp_filename = os.path.join(figpath,ftp_file) | |
|
619 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
|
620 | # self.counter_imagwr = 0 | |
|
621 | # | |
|
622 | # self.counter_imagwr = 0 | |
|
623 | ||
|
624 | #if ((dataOut.utctime-time.timezone) >= self.axesList[0].xmax): | |
|
625 | self.saveFigure(figpath, figfile) | |
|
626 | 591 | if x[1] >= self.axesList[0].xmax: |
|
627 | self.saveFigure(figpath, figfile) | |
|
628 | self.isConfig = False | |
|
592 | self.counter_imagwr = wr_period | |
|
593 | self.__isConfig = False | |
|
594 | ||
|
595 | if figfile == None: | |
|
596 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
|
597 | figfile = self.getFilename(name = str_datetime) | |
|
598 | ||
|
599 | if figpath != '': | |
|
629 | 600 | |
|
630 | # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
|
631 | # | |
|
632 | # self.isConfig = False | |
|
633 | ||
|
634 | # if lastone: | |
|
635 | # if figfile == None: | |
|
636 | # figfile = self.getFilename(name = self.name) | |
|
637 |
|
|
|
638 |
|
|
|
639 | # if ftp: | |
|
640 | # #provisionalmente envia archivos en el formato de la web en tiempo real | |
|
641 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
642 | # path = '%s%03d' %(self.PREFIX, self.id) | |
|
643 | # ftp_file = os.path.join(path,'ftp','%s.png'%name) | |
|
644 | # self.saveFigure(figpath, ftp_file) | |
|
645 | # ftp_filename = os.path.join(figpath,ftp_file) | |
|
646 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
|
601 | self.counter_imagwr += 1 | |
|
602 | if (self.counter_imagwr>=wr_period): | |
|
603 | # store png plot to local folder | |
|
604 | self.saveFigure(figpath, figfile) | |
|
605 | # store png plot to FTP server according to RT-Web format | |
|
606 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
607 | ftp_filename = os.path.join(figpath, name) | |
|
608 | self.saveFigure(figpath, ftp_filename) | |
|
609 | ||
|
610 | self.counter_imagwr = 0 | |
|
611 | ||
|
647 | 612 | |
|
648 | 613 | class CoherenceMap(Figure): |
|
649 | 614 | isConfig = None |
@@ -778,12 +743,6 class CoherenceMap(Figure): | |||
|
778 | 743 | for i in range(self.nplots): |
|
779 | 744 | |
|
780 | 745 | pair = dataOut.pairsList[pairsIndexList[i]] |
|
781 | # coherenceComplex = dataOut.data_cspc[pairsIndexList[i],:,:]/numpy.sqrt(dataOut.data_spc[pair[0],:,:]*dataOut.data_spc[pair[1],:,:]) | |
|
782 | # avgcoherenceComplex = numpy.average(coherenceComplex, axis=0) | |
|
783 | # coherence = numpy.abs(avgcoherenceComplex) | |
|
784 | ||
|
785 | ## coherence = numpy.abs(coherenceComplex) | |
|
786 | ## avg = numpy.average(coherence, axis=0) | |
|
787 | 746 | |
|
788 | 747 | ccf = numpy.average(dataOut.data_cspc[pairsIndexList[i],:,:],axis=0) |
|
789 | 748 | powa = numpy.average(dataOut.data_spc[pair[0],:,:],axis=0) |
@@ -814,9 +773,9 class CoherenceMap(Figure): | |||
|
814 | 773 | grid='x') |
|
815 | 774 | |
|
816 | 775 | counter += 1 |
|
817 | # phase = numpy.arctan(-1*coherenceComplex.imag/coherenceComplex.real)*180/numpy.pi | |
|
776 | ||
|
818 | 777 | phase = numpy.arctan2(avgcoherenceComplex.imag, avgcoherenceComplex.real)*180/numpy.pi |
|
819 | # avg = numpy.average(phase, axis=0) | |
|
778 | ||
|
820 | 779 | z = phase.reshape((1,-1)) |
|
821 | 780 | |
|
822 | 781 | title = "Phase %d%d: %s" %(pair[0], pair[1], thisDatetime.strftime("%d-%b-%Y %H:%M:%S")) |
@@ -838,32 +797,25 class CoherenceMap(Figure): | |||
|
838 | 797 | self.draw() |
|
839 | 798 | |
|
840 | 799 | if x[1] >= self.axesList[0].xmax: |
|
841 | self.saveFigure(figpath, figfile) | |
|
842 | self.isConfig = False | |
|
800 | self.counter_imagwr = wr_period | |
|
801 | self.__isConfig = False | |
|
843 | 802 | |
|
844 | # if save: | |
|
845 | # | |
|
846 | # self.counter_imagwr += 1 | |
|
847 | # if (self.counter_imagwr==wr_period): | |
|
848 | # if figfile == None: | |
|
849 | # figfile = self.getFilename(name = self.name) | |
|
850 | # self.saveFigure(figpath, figfile) | |
|
851 | # | |
|
852 | # if ftp: | |
|
853 | # #provisionalmente envia archivos en el formato de la web en tiempo real | |
|
854 | # name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
855 | # path = '%s%03d' %(self.PREFIX, self.id) | |
|
856 |
|
|
|
857 |
|
|
|
858 | # ftp_filename = os.path.join(figpath,ftp_file) | |
|
859 | # self.sendByFTP_Thread(ftp_filename, server, folder, username, password) | |
|
860 | # self.counter_imagwr = 0 | |
|
861 | # | |
|
862 | # self.counter_imagwr = 0 | |
|
863 | # | |
|
864 | # | |
|
865 | # if x[1] + (x[1]-x[0]) >= self.axesList[0].xmax: | |
|
866 | # self.isConfig = False | |
|
803 | if figfile == None: | |
|
804 | str_datetime = thisDatetime.strftime("%Y%m%d_%H%M%S") | |
|
805 | figfile = self.getFilename(name = str_datetime) | |
|
806 | ||
|
807 | if figpath != '': | |
|
808 | ||
|
809 | self.counter_imagwr += 1 | |
|
810 | if (self.counter_imagwr>=wr_period): | |
|
811 | # store png plot to local folder | |
|
812 | self.saveFigure(figpath, figfile) | |
|
813 | # store png plot to FTP server according to RT-Web format | |
|
814 | name = self.getNameToFtp(thisDatetime, self.FTP_WEI, self.EXP_CODE, self.SUB_EXP_CODE, self.PLOT_CODE, self.PLOT_POS) | |
|
815 | ftp_filename = os.path.join(figpath, name) | |
|
816 | self.saveFigure(figpath, ftp_filename) | |
|
817 | ||
|
818 | self.counter_imagwr = 0 | |
|
867 | 819 | |
|
868 | 820 | class PowerProfile(Figure): |
|
869 | 821 | isConfig = None |
@@ -14,46 +14,42 controllerObj.setup(id = '191', name='test01', description=desc) | |||
|
14 | 14 | |
|
15 | 15 | path='/remote/ewdrifts/RAW_EXP/EW_DRIFT_FARADAY/EW_Drift' |
|
16 | 16 | |
|
17 | path = '/Users/dsuarez/Documents/Radar/drifts' | |
|
18 | path = '/Users/dsuarez/Documents/EW_DRIFT_WITH_TR' | |
|
19 | path = '/home/administrator/Radar/drifts/2014' | |
|
20 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
|
17 | ||
|
18 | path = '/home/signalchain/Puma/2014_07/EW_Drift' | |
|
19 | ||
|
20 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |
|
21 | 21 | path=path, |
|
22 |
startDate='2014/0 |
|
|
23 |
endDate='2014/ |
|
|
22 | startDate='2014/07/01', | |
|
23 | endDate='2014/07/30', | |
|
24 | 24 | startTime='00:00:00', |
|
25 | 25 | endTime='23:59:59', |
|
26 | 26 | online=0, |
|
27 | 27 | delay=5, |
|
28 | 28 | walk=0) |
|
29 | 29 | |
|
30 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
|
30 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') | |
|
31 | 31 | |
|
32 | opObj11 = procUnitConfObj0.addOperation(name='Scope', optype='other') | |
|
33 | opObj11.addParameter(name='id', value='101', format='int') | |
|
34 | opObj11.addParameter(name='wintitle', value='AMISR', format='str') | |
|
32 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
|
35 | 33 | |
|
36 | # | |
|
37 | # opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') | |
|
38 | # opObj11.addParameter(name='profileRangeList', value='0,127', format='intlist') | |
|
39 | # | |
|
40 | # opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') | |
|
41 | # opObj11.addParameter(name='window', value='3', format='int') | |
|
42 | # | |
|
43 | # opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
|
44 | # | |
|
45 | # | |
|
46 | # procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
|
47 | # procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int') | |
|
48 | # procUnitConfObj1.addParameter(name='nProfiles', value='128', format='int') | |
|
49 | # | |
|
50 | # | |
|
51 | # opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
|
52 | # opObj11.addParameter(name='timeInterval', value='60', format='float') | |
|
53 | # | |
|
54 | # opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
|
55 | # opObj11.addParameter(name='id', value='100', format='int') | |
|
56 | # opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |
|
34 | opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') | |
|
35 | opObj11.addParameter(name='profileRangeList', value='0,127', format='intlist') | |
|
36 | ||
|
37 | opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') | |
|
38 | opObj11.addParameter(name='window', value='3', format='int') | |
|
39 | ||
|
40 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') | |
|
41 | ||
|
42 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
|
43 | procUnitConfObj1.addParameter(name='nFFTPoints', value='128', format='int') | |
|
44 | procUnitConfObj1.addParameter(name='nProfiles', value='128', format='int') | |
|
45 | ||
|
46 | ||
|
47 | opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
|
48 | opObj11.addParameter(name='timeInterval', value='60', format='float') | |
|
49 | ||
|
50 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') | |
|
51 | opObj11.addParameter(name='id', value='100', format='int') | |
|
52 | opObj11.addParameter(name='wintitle', value='SpectraPlot', format='str') | |
|
57 | 53 | # #opObj11.addParameter(name='channelList', value='0,1,2,3', format='intlist') |
|
58 | 54 | # # opObj11.addParameter(name='zmin', value='0', format='int') |
|
59 | 55 | # # opObj11.addParameter(name='zmax', value='100', format='int') |
@@ -74,7 +70,7 opObj11.addParameter(name='wintitle', value='AMISR', format='str') | |||
|
74 | 70 | |
|
75 | 71 | # |
|
76 | 72 | #opObj11 = procUnitConfObj1.addOperation(name='PowerProfilePlot', optype='other') |
|
77 |
#opObj11.addParameter(name='id |
|
|
73 | #opObj11.addParameter(name='id', value='2', format='int') | |
|
78 | 74 | #opObj11.addParameter(name='channelList', value='0,1,2,3', format='intlist') |
|
79 | 75 | #opObj11.addParameter(name='save', value='1', format='bool') |
|
80 | 76 | #opObj11.addParameter(name='figpath', value='/home/dsuarez/Pictures/EW_DRIFTS_2012_DEC', format='str') |
@@ -82,7 +78,7 opObj11.addParameter(name='wintitle', value='AMISR', format='str') | |||
|
82 | 78 | ##opObj11.addParameter(name='xmax', value='40', format='int') |
|
83 | 79 | # |
|
84 | 80 | # opObj11 = procUnitConfObj1.addOperation(name='CrossSpectraPlot', optype='other') |
|
85 |
# opObj11.addParameter(name='id |
|
|
81 | # opObj11.addParameter(name='id', value='3', format='int') | |
|
86 | 82 | # opObj11.addParameter(name='wintitle', value='CrossSpectraPlot', format='str') |
|
87 | 83 | # #opObj11.addParameter(name='save', value='1', format='bool') |
|
88 | 84 | # #opObj11.addParameter(name='figpath', value='/home/dsuarez/Pictures/EW_DRIFTS_2012_DEC', format='str') |
@@ -12,78 +12,60 controllerObj = Project() | |||
|
12 | 12 | |
|
13 | 13 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
14 | 14 | |
|
15 | path = '/home/dsuarez/EW_Faraday_imaging' | |
|
16 | path = '/media/datos/IMAGING/IMAGING/abril2014' | |
|
15 | path = '/media/signalchain/datos/IMAGING/IMAGING/setiembre2014' | |
|
17 | 16 | |
|
18 | readUnitConfObj = controllerObj.addReadUnit(datatype='Spectra', | |
|
17 | readUnitConfObj = controllerObj.addReadUnit(datatype='SpectraReader', | |
|
19 | 18 | path=path, |
|
20 |
startDate='201 |
|
|
21 |
endDate='201 |
|
|
22 |
startTime=' |
|
|
19 | startDate='2014/09/22', | |
|
20 | endDate='2014/09/22', | |
|
21 | startTime='00:30:00', | |
|
23 | 22 | endTime='23:59:59', |
|
24 |
delay= |
|
|
25 |
online= |
|
|
23 | delay=5, | |
|
24 | online=0, | |
|
26 | 25 | walk=1) |
|
27 | 26 | |
|
28 | 27 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
29 | 28 | |
|
30 | 29 | ######################## IMAGING ############################################# |
|
31 | 30 | |
|
32 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=readUnitConfObj.getId()) | |
|
33 | ||
|
34 | ||
|
35 | # opObj11 = procUnitConfObj1.addOperation(name='IncohInt', optype='other') | |
|
36 | # opObj11.addParameter(name='n', value='2', format='float') | |
|
31 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=readUnitConfObj.getId()) | |
|
37 | 32 | |
|
38 | 33 | opObj11 = procUnitConfObj1.addOperation(name='SpectraPlot', optype='other') |
|
39 | 34 | opObj11.addParameter(name='id', value='2000', format='int') |
|
40 | 35 | opObj11.addParameter(name='wintitle', value='Imaging', format='str') |
|
41 |
|
|
|
42 |
|
|
|
43 |
|
|
|
44 | # opObj11.addParameter(name='ymax', value='300', format='int') | |
|
45 | opObj11.addParameter(name='save', value='1', format='int') | |
|
46 | opObj11.addParameter(name='figpath', value='/home/dsuarez/Pictures/imaging_abril2014', format='str') | |
|
47 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
48 | opObj11.addParameter(name='ftp', value='1', format='int') | |
|
49 | opObj11.addParameter(name='server', value='jro-app.igp.gob.pe', format='str') | |
|
50 | opObj11.addParameter(name='folder', value='/home/wmaster/graficos', format='str') | |
|
51 | opObj11.addParameter(name='username', value='wmaster', format='str') | |
|
52 | opObj11.addParameter(name='password', value='mst2010vhf', format='str') | |
|
53 | opObj11.addParameter(name='ftp_wei', value='0', format='int') | |
|
36 | opObj11.addParameter(name='zmin', value='15', format='int') | |
|
37 | opObj11.addParameter(name='zmax', value='45', format='int') | |
|
38 | opObj11.addParameter(name='figpath', value='/home/signalchain/Pictures/imaging', format='str') | |
|
54 | 39 | opObj11.addParameter(name='exp_code', value='13', format='int') |
|
55 | opObj11.addParameter(name='sub_exp_code', value='0', format='int') | |
|
56 | opObj11.addParameter(name='plot_pos', value='0', format='int') | |
|
57 | ||
|
58 | # opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
|
59 |
|
|
|
60 |
|
|
|
61 |
|
|
|
62 |
|
|
|
63 |
|
|
|
64 |
|
|
|
65 |
|
|
|
66 |
|
|
|
67 | # opObj11.addParameter(name='ftpratio', value='3', format='int') | |
|
68 | ||
|
69 | ||
|
40 | ||
|
41 | opObj11 = procUnitConfObj1.addOperation(name='RTIPlot', optype='other') | |
|
42 | opObj11.addParameter(name='id', value='3001', format='int') | |
|
43 | opObj11.addParameter(name='wintitle', value='Imaging', format='str') | |
|
44 | opObj11.addParameter(name='xmin', value='20.5', format='float') | |
|
45 | opObj11.addParameter(name='xmax', value='24', format='float') | |
|
46 | opObj11.addParameter(name='zmin', value='15', format='int') | |
|
47 | opObj11.addParameter(name='zmax', value='45', format='int') | |
|
48 | opObj11.addParameter(name='channelList', value='0,1,2,3', format='intlist') | |
|
49 | opObj11.addParameter(name='showprofile', value='0', format='int') | |
|
50 | opObj11.addParameter(name='figpath', value='/home/signalchain/Pictures/imaging', format='str') | |
|
51 | opObj11.addParameter(name='exp_code', value='13', format='int') | |
|
52 | ||
|
70 | 53 | opObj11 = procUnitConfObj1.addOperation(name='CoherenceMap', optype='other') |
|
71 | 54 | opObj11.addParameter(name='id', value='2001', format='int') |
|
72 | 55 | opObj11.addParameter(name='wintitle', value='Imaging', format='str') |
|
73 |
opObj11.addParameter(name='xmin', value=' |
|
|
56 | opObj11.addParameter(name='xmin', value='20.5', format='float') | |
|
74 | 57 | opObj11.addParameter(name='xmax', value='24', format='float') |
|
75 |
opObj11.addParameter(name=' |
|
|
76 |
opObj11.addParameter(name=' |
|
|
77 | opObj11.addParameter(name='wr_period', value='5', format='int') | |
|
78 | opObj11.addParameter(name='ftp', value='1', format='int') | |
|
58 | opObj11.addParameter(name='figpath', value='/home/signalchain/Pictures/imaging', format='str') | |
|
59 | opObj11.addParameter(name='exp_code', value='13', format='int') | |
|
60 | ||
|
61 | opObj11 = procUnitConfObj1.addOperation(name='SendByFTP', optype='other') | |
|
62 | opObj11.addParameter(name='ext', value='*.png', format='str') | |
|
63 | opObj11.addParameter(name='localfolder', value='/home/signalchain/Pictures/imaging', format='str') | |
|
64 | opObj11.addParameter(name='remotefolder', value='/home/wmaster/graficos', format='str') | |
|
79 | 65 | opObj11.addParameter(name='server', value='jro-app.igp.gob.pe', format='str') |
|
80 | opObj11.addParameter(name='folder', value='/home/wmaster/graficos', format='str') | |
|
81 | 66 | opObj11.addParameter(name='username', value='wmaster', format='str') |
|
82 | 67 | opObj11.addParameter(name='password', value='mst2010vhf', format='str') |
|
83 | opObj11.addParameter(name='ftp_wei', value='0', format='int') | |
|
84 | opObj11.addParameter(name='exp_code', value='13', format='int') | |
|
85 | opObj11.addParameter(name='sub_exp_code', value='0', format='int') | |
|
86 | opObj11.addParameter(name='plot_pos', value='0', format='int') | |
|
68 | ||
|
87 | 69 | |
|
88 | 70 | print "Escribiendo el archivo XML" |
|
89 | 71 | controllerObj.writeXml(filename) |
@@ -12,14 +12,12 controllerObj = Project() | |||
|
12 | 12 | |
|
13 | 13 | controllerObj.setup(id = '191', name='test01', description=desc) |
|
14 | 14 | |
|
15 | path = '/remote' | |
|
16 | path = '/home/dsuarez/.gvfs/data on 10.10.20.13/EW_Faraday_imaging/d2013270' | |
|
17 | path = '/home/dsuarez/.gvfs/data on 10.10.20.13/EW_Faraday_imaging' | |
|
15 | path = '/home/signalchain/Documents/remote_data/EW_Faraday_imaging' | |
|
18 | 16 | |
|
19 | readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |
|
17 | readUnitConfObj = controllerObj.addReadUnit(datatype='VoltageReader', | |
|
20 | 18 | path=path, |
|
21 |
startDate='2014/0 |
|
|
22 |
endDate='2014/0 |
|
|
19 | startDate='2014/09/21', | |
|
20 | endDate='2014/09/30', | |
|
23 | 21 | startTime='16:00:00', |
|
24 | 22 | endTime='23:59:59', |
|
25 | 23 | delay=5, |
@@ -29,28 +27,19 readUnitConfObj = controllerObj.addReadUnit(datatype='Voltage', | |||
|
29 | 27 | opObj11 = readUnitConfObj.addOperation(name='printNumberOfBlock') |
|
30 | 28 | |
|
31 | 29 | ######################## IMAGING ############################################# |
|
32 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='Voltage', inputId=readUnitConfObj.getId()) | |
|
30 | procUnitConfObj0 = controllerObj.addProcUnit(datatype='VoltageProc', inputId=readUnitConfObj.getId()) | |
|
33 | 31 | # |
|
34 | 32 | opObj11 = procUnitConfObj0.addOperation(name='ProfileSelector', optype='other') |
|
35 | 33 | opObj11.addParameter(name='profileRangeList', value='0,39', format='intlist') |
|
36 | 34 | # opObj11.addParameter(name='profileRangeList', value='40,167', format='intlist') |
|
37 | 35 | |
|
38 | # opObj11 = procUnitConfObj0.addOperation(name='filterByHeights') | |
|
39 | # opObj11.addParameter(name='window', value='4', format='int') | |
|
40 | 36 | |
|
41 | 37 | opObj11 = procUnitConfObj0.addOperation(name='Decoder', optype='other') |
|
42 | 38 | # opObj11.addParameter(name='code', value='1,0,0,1,0,0,-1,0,0,-1,0,0,-1,0,0,1,0,0', format='floatlist') |
|
43 | 39 | # opObj11.addParameter(name='nCode', value='2', format='int') |
|
44 | 40 | # opObj11.addParameter(name='nBaud', value='9', format='int') |
|
45 | 41 | |
|
46 | #opObj11 = procUnitConfObj0.addOperation(name='selectHeights') | |
|
47 | #opObj11.addParameter(name='maxHei', value='300', format='float') | |
|
48 | ||
|
49 | #opObj11 = procUnitConfObj0.addOperation(name='selectHeights') | |
|
50 | #opObj11.addParameter(name='minHei', value='300', format='float') | |
|
51 | #opObj11.addParameter(name='maxHei', value='600', format='float') | |
|
52 | ||
|
53 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='Spectra', inputId=procUnitConfObj0.getId()) | |
|
42 | procUnitConfObj1 = controllerObj.addProcUnit(datatype='SpectraProc', inputId=procUnitConfObj0.getId()) | |
|
54 | 43 | procUnitConfObj1.addParameter(name='nProfiles', value='40', format='int') |
|
55 | 44 | procUnitConfObj1.addParameter(name='nFFTPoints', value='40', format='int') |
|
56 | 45 | |
@@ -68,7 +57,7 opObj11.addParameter(name='timeInterval', value='5', format='float') | |||
|
68 | 57 | |
|
69 | 58 | |
|
70 | 59 | opObj11 = procUnitConfObj1.addOperation(name='SpectraWriter', optype='other') |
|
71 |
opObj11.addParameter(name='path', value='/media/datos/IMAGING/IMAGING/ |
|
|
60 | opObj11.addParameter(name='path', value='/media/signalchain/datos/IMAGING/IMAGING/setiembre2014') | |
|
72 | 61 | opObj11.addParameter(name='blocksPerFile', value='10', format='int') |
|
73 | 62 | |
|
74 | 63 |
General Comments 0
You need to be logged in to leave comments.
Login now