text stringlengths 1 93.6k |
|---|
# we need to sort these low-to-high so they match the order of the
|
# contour_differences we just generated
|
dissolved_lines = []
|
for key in keys:
|
geometries = [f.geometry() for f in contour_dict[key]]
|
combined_geo = QgsGeometry.collectGeometry(geometries)
|
dissolved_lines.append(combined_geo)
|
# then turn them into Contours for use by the main loop
|
contour_lines = []
|
for dissolved_line,poly_geometry in zip(dissolved_lines,contour_differences):
|
contour_lines.append(Contour(dissolved_line,poly_geometry))
|
#each Contour carrys a record of its corresponding poly for use by haircut
|
instance.removeMapLayer(filled_contours) # no longer needed
|
#========MAIN LOOP: Iterate through Contours to generate hachures=======
|
current_hachures = None
|
# As we iterate through, it's possible that it takes a few contour lines
|
# before the slope is high enough (i.e. > min_slope) to make hachures.
|
# So each time, the if statement checks to see if we got anything back.
|
# Otherwise it moves to the next line and again tries to generate
|
# a set of starting hachures.
|
for line in contour_lines:
|
if current_hachures:
|
subsequent_contour(line)
|
else:
|
first_contour(line)
|
# We sometimes pick up errant duplicates, so let's clean the final list
|
current_hachures = list(set(current_hachures))
|
# Add it to the map & also add length attributes so user can filter
|
hachureLayer = QgsVectorLayer('linestring','Hachures','memory')
|
hachureLayer.setCrs(crs)
|
field = QgsField('Length', QVariant.Double)
|
hachureLayer.dataProvider().addAttributes([field])
|
hachureLayer.updateFields()
|
for feature in current_hachures:
|
feature.setAttributes([feature.geometry().length()])
|
with edit(hachureLayer):
|
hachureLayer.dataProvider().addFeatures(current_hachures)
|
instance.addMapLayer(hachureLayer)
|
# <FILESEP>
|
#!/usr/bin/env python2.7
|
import scipy.misc
|
import argparse
|
import os
|
import sys
|
import audioop
|
import numpy
|
import glob
|
import scipy
|
import subprocess
|
import wave
|
import cPickle
|
import threading
|
import shutil
|
import ntpath
|
import random
|
import matplotlib.pyplot as plt
|
from pyAudioAnalysis import audioFeatureExtraction as aF
|
from pyAudioAnalysis import audioTrainTest as aT
|
from pyAudioAnalysis import audioSegmentation as aS
|
from pyAudioAnalysis import audioVisualization as aV
|
from pyAudioAnalysis import audioBasicIO
|
from pyAudioAnalysis import utilities as uT
|
import scipy.io.wavfile as wavfile
|
import matplotlib.patches
|
import Image
|
import cv2
|
import matplotlib.cm
|
def createSpectrogramFile(x, Fs, fileName, stWin, stStep):
|
specgramOr, TimeAxis, FreqAxis = aF.stSpectogram(x, Fs, round(Fs * stWin), round(Fs * stStep), False)
|
print specgramOr.shape
|
if inputs[2]=='full':
|
print specgramOr
|
numpy.save(fileName.replace('.png','')+'_spectrogram', specgramOr)
|
else:
|
#specgram = scipy.misc.imresize(specgramOr, float(227.0) / float(specgramOr.shape[0]), interp='bilinear')
|
specgram = cv2.resize(specgramOr,(227, 227), interpolation = cv2.INTER_LINEAR)
|
im1 = Image.fromarray(numpy.uint8(matplotlib.cm.jet(specgram)*255))
|
scipy.misc.imsave(fileName, im1)
|
def main(argv):
|
if argv[2]=='full':
|
dirName = argv[1]
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.