pScene = drawing.projectToMap((xScene, yScene)) print 'and back again, to siteMap, p = (%s, %s)' % pScene print 'scaling to scene, siteMap.xFederal maps to %s' % drawing.scaleToScene(xFed) print 'and this maps back to %s' % drawing.scaleToMap(drawing.scaleToScene(xFed)) #=============================================================================== # place a circle of radius 5 at (100.0, 100.0) in scene coordinates # drawing.circle((100, 100), 5, scene=True, stroke='red', fill='green') # label it with text at (100, 10) drawing.text("circle of radius 5 at (200, 10)", (100, 10), scene=True, stroke='blue') # now place another circle and rect in map (not scene) coordinates below the federal marker drawing.rect((xScene, yScene - 100), 4, 10, scene=False, fill='red') # and another at (100, 200), also in map coordinates drawing.rect((100, 200), 10, 4, scene=False) #================================================================================================== # CREATE A GROUP CONTAINING A RECT, SHOWING HOW TO USE (INSTANCE) IT ROTATED AND TRANSLATED drawing.createGroup('r1') drawing.rect((0, 0), 10, 30, scene=False, groupId='r1') # add this rect to the group drawing.use('r1', (400, 100), rotation=10, fill='blue') drawing.use('r1', (400, 200), rotation=20, fill='blue') drawing.use('r1', (400, 300), rotation=30, fill='blue') drawing.use('r1', (400, 400), rotation=40, fill='blue')
fMap = (xFed, yFed) fScene = drawing.projectToScene((xFed, yFed)) print "siteMap.index = %s and siteMap.name = %s" % (siteMap.index, siteMap.filename) print 'in siteMap, the federal marker is (%s, %s)' % fMap print 'which projects into the scene as (%s, %s)' % (fScene[0], fScene[1]) print 'and projecting back to the map gives (%s, %s)' % drawing.projectToMap((fScene[0], fScene[1])) # place a circle of radius 5 at (10.0, 10.0) in scene coordinates drawing.circle((10, 10), 5) # label it with text at (20, 10) drawing.text("circle of radius 5", (20, 10), scene=True) # now place a 20x40 rect in map coordinates (not scene coordinates) at the federal marker drawing.rect((xFed + 40, yFed), 20, 40, scene=False) # and another smaller one at (10, 20) in map coordinates drawing.rect((10, 20), 4, 8, scene=False) # place the federal coordinates as a text string 20 cm above the marker text = "(%s, %s)" % (drawing.siteMap.federalEast, drawing.siteMap.federalNorth) drawing.text(text, (0, 20), scene=True, stroke='green') # place a 2 cm green unfilled circle atop the federal coordinate marker drawing.circle((0, 0), 2, scene=True, fill='none', stroke='green', stroke_width=1) # place a grid in registration with the 10m grid in the site map, and illustrates the use of a # group which is then instanced multiple times across a drawing. drawing.grid()
lengthRatio = 0.5 trackLength = 1.0 trackWidth = 1.0 trackRotation = 15.0 # place a circle of radius 5 at (10.0, 10.0) in scene coordinates drawing.circle((10, 10), 5, fill='none') drawing.line((100,100), (200, 100), scene=True, stroke='red', stroke_width=4) # label it with text at (20, 10) drawing.text("circle of radius 5", (20, 10), scene=True) # now place another circle and rect in map coordinates (not scene coordinates) at the federal marker drawing.rect((xFed + 40, yFed), 20, 20, fill='none', scene=False) # now overlay onto the above measured-dimension bars the corresponding length indicators drawing.use( 'bar', (100, 200), scale=1.0, scaleY=lengthRatio*trackLength, rotation=trackRotation, scene=True, stroke='red', stroke_width=2.0) # draw the remaining portion of the length bar
def _postAnalyze(self): h = Histogram( data=self._uncs, binCount=80, xLimits=(0, max(*self._uncs)), color="r", title="Distribution of Rotational Uncertainties", xLabel="Uncertainty Value (degrees)", yLabel="Frequency", ) p1 = h.save(self.getTempFilePath(extension="pdf")) h.isLog = True h.title += " (log)" p2 = h.save(self.getTempFilePath(extension="pdf")) self.mergePdfs([p1, p2], self.getPath("Rotational-Uncertainty-Distribution.pdf")) average = NumericUtils.getMeanAndDeviation(self._uncs) self.logger.write("Average rotational uncertainty: %s" % average.label) # ------------------------------------------------------------------------------------------- # FIND LARGE UNCERTAINTY TRACKS largeUncertaintyCount = 0 drawing = None sitemap = None # If track uncertainty is 2x average, add that track to the spreadsheet and map overlay for t in self._tracks: # if the tracksite has changed, save previous map and make a new one if sitemap != t.trackSeries.trackway.sitemap: # save the last site map drawing (if there was one) if drawing: drawing.save() # then start a new drawing for this new site map sitemap = t.trackSeries.trackway.sitemap fileName = "%s-%s-ROTATION_UNC.svg" % (sitemap.name, sitemap.level) path = self.getPath(self.DRAWING_FOLDER_NAME, fileName, isFile=True) drawing = CadenceDrawing(path, sitemap) # create a group to be instanced for the spreadsheet values drawing.createGroup("rect1") # create a rectangle of 100x100 cm that is to be scaled by fractional meters drawing.rect((0, 0), 100, 100, scene=True, groupId="rect1") # create another group to be instanced for the mapped values. drawing.createGroup("rect2") # create a rectangle of 100x100 cm that is to be scaled by fractional meters drawing.rect((0, 0), 100, 100, scene=True, groupId="rect2") # and place a grid and the federal coordinates in the drawing file drawing.grid() drawing.federalCoordinates() # now examine the positional uncertainties for this track rotation = t.rotationAngle.valueDegrees if rotation.uncertainty <= 2.0 * average.uncertainty: # then just indicate that this track has low uncertainty self._drawLowUncertaintyMarker(drawing, t) # label this track green # drawing.text( # t.name, # (t.x - 20, t.z), # scene=True, # stroke='green', # stroke_width='0.25', # font_size='8px', # font_family='Arial') continue # else, since the uncertainty is high, first write that track in the spreadsheet largeUncertaintyCount += 1 self._largeUncCsv.createRow(uid=t.uid, fingerprint=t.fingerprint, r=rotation.label) # if either the measured width or length is 0, mark with a yellow disk with red outline if t.rotationMeasured == 0: drawing.circle( (t.x, t.z), 100 * (t.widthUncertainty + t.lengthUncertainty) / 2.0, scene=True, fill="yellow", stroke="red", ) # drawing.text( # t.name, # (t.x - 20, t.z), # scene=True, # stroke='black', # stroke_width='0.25', # font_size='6px', # font_family='Arial') continue self._drawHighUncertaintyMarker(drawing, t) # label this track with red # drawing.text( # t.name, # (t.x - 20, t.z), # scene=True, # stroke='red', # stroke_width='0.25', # font_size='6px', # font_family='Arial') # and close off with a final save of the drawing file if drawing: drawing.save() self.logger.write( "%s Tracks with large rotational uncertainties found (%s%%)" % ( largeUncertaintyCount, NumericUtils.roundToOrder(100.0 * float(largeUncertaintyCount) / float(len(self._tracks)), -1), ) ) self._largeUncCsv.save() self._tracks = []
def _postAnalyze(self): h = Histogram( data=self._uncs, binCount=80, xLimits=(0, max(*self._uncs)), color='r', title='Distribution of Spatial (X, Z) Uncertainties', xLabel='Uncertainty Value (m)', yLabel='Frequency') p1 = h.save(self.getTempFilePath(extension='pdf')) h.isLog = True h.title += ' (log)' p2 = h.save(self.getTempFilePath(extension='pdf')) self.mergePdfs([p1, p2], self.getPath('Spatial-Uncertainty-Distribution.pdf')) average = NumericUtils.getMeanAndDeviation(self._uncs) self.logger.write('Average spatial uncertainty: %s' % average.label) #------------------------------------------------------------------------------------------- # FIND LARGE UNCERTAINTY TRACKS largeUncertaintyCount = 0 drawing = None sitemap = None # If track uncertainty is 2x average, add that track to the spreadsheet and map overlay for t in self._tracks: # if the tracksite has changed, save previous map and make a new one if sitemap != t.trackSeries.trackway.sitemap: # save the last site map drawing (if there was one) if drawing: drawing.save() # then start a new drawing for this new site map sitemap = t.trackSeries.trackway.sitemap fileName = sitemap.name + "_" + sitemap.level + '_uncertainty.svg' path = self.getPath(self.DRAWING_FOLDER_NAME, fileName, isFile=True) drawing = CadenceDrawing(path, sitemap) # create a group to be instanced for the spreadsheet values drawing.createGroup('rect1') # create a rectangle of 100x100 cm that is to be scaled by fractional meters drawing.rect((0, 0), 100, 100, scene=True, groupId='rect1') # create another group to be instanced for the mapped values. drawing.createGroup('rect2') # create a rectangle of 100x100 cm that is to be scaled by fractional meters drawing.rect((0, 0), 100, 100, scene=True, groupId='rect2') # and place a grid and the federal coordinates in the drawing file drawing.grid() drawing.federalCoordinates() # now examine the positional uncertainties for this track x = t.xValue z = t.zValue if x.uncertainty > 0.15 or z.uncertainty > 0.15: # s = '%s%s %s%s: %s %s'% ( # t.site, t.level, t.trackwayType, t.trackwayNumber, t.name, t.uid) # print('%s: (%s and %s)' % (s, x.uncertainty, z.uncertainty)) print('%s\t%s' % (t.uid, t.fingerprint)) if max(x.uncertainty, z.uncertainty) <= 2.0*average.uncertainty: # then just indicate that this track has low uncertainty self._drawLowUncertaintyMarker(drawing, t) # label this track with green drawing.text( t.name, (t.x - 20, t.z), scene=True, stroke='green', stroke_width='0.25', font_size='8px', font_family='Arial') continue # else, since the uncertainty is high, first write that track in the spreadsheet largeUncertaintyCount += 1 self._largeUncCsv.createRow( uid=t.uid, fingerprint=t.fingerprint, x=x.label, z=z.label) # if either the measured width or length is 0, mark with a yellow disk with red outline if t.widthMeasured == 0 or t.lengthMeasured == 0: drawing.circle( (t.x, t.z), 100*(t.widthUncertainty + t.lengthUncertainty)/2.0, scene=True, fill='yellow', stroke='red') drawing.text( t.name, (t.x - 20, t.z), scene=True, stroke='black', stroke_width='0.25', font_size='6px', font_family='Arial') continue self._drawHighUncertaintyMarker(drawing, t) # label this track with red drawing.text( t.name, (t.x - 20, t.z), scene=True, stroke='red', stroke_width='0.25', font_size='6px', font_family='Arial') # # # draw this track indicating it has high uncertainty # drawing.use( # 'rect1', # (t.x, t.z), # scene=True, # rotation=t.rotation, # opacity='0.5', # scale=t.widthMeasured, # scaleY=t.lengthMeasured, # fill='red', # stroke='red') # # # draw the map dimensions with an outline gray rectangle # drawing.use( # 'rect2', # (t.x, t.z), # scene=True, # rotation=t.rotation, # scale=t.width, # scaleY=t.length, # fill='none', # stroke='gray') # and close off with a final save of the drawing file if drawing: drawing.save() self.logger.write('%s Tracks with large spatial uncertainties found (%s%%)' % ( largeUncertaintyCount, NumericUtils.roundToOrder( 100.0*float(largeUncertaintyCount)/float(len(self._tracks)), -1) )) self._largeUncCsv.save() self._tracks = []
print 'in siteMap, xFederal = %s and yFederal = %s' % fMap print 'in scene, xFederal = %s and yFederal = %s' % (xScene, yScene) pScene = drawing.projectToMap((xScene, yScene)) print 'and back again, to siteMap, p = (%s, %s)' % pScene print 'scaling to scene, siteMap.xFederal maps to %s' % drawing.scaleToScene(xFed) print 'and this maps back to %s' % drawing.scaleToMap(drawing.scaleToScene(xFed)) #================================================================================================== # CREATE A GROUP CONTAINING A CIRCLE, SHOWING HOW TO 'USE' (INSTANCE) IT SCALED drawing.createGroup('rect') drawing.rect((50, 0), 100, 4, scene=False, groupId='rect') drawing.createGroup('rect2') drawing.rect((0, 0), -200, 100, scene=False, groupId='rect2') drawing.createGroup('circ') drawing.circle((0, 0), 50, scene=False,