Skip to content

Instantly share code, notes, and snippets.

@hobu
Created April 30, 2017 13:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hobu/ab1f9d3637c9a698b3e9a17682b56637 to your computer and use it in GitHub Desktop.
Save hobu/ab1f9d3637c9a698b3e9a17682b56637 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -- $(iostat)
read -d '' script <<"EOF"
import numpy as np
import numpy
import scipy.signal
def moving_average(ins,outs):
y = ins["Y"]
avg = ins["Avg"]
median = numpy.median(y)
stddev = numpy.std(y)
print ("median", median)
print ("stddev", stddev)
outs = np.where( abs(y-median) > 3*stddev)
for i in outs:
print y[i]
print outs
return True
EOF
read -d '' pipeline <<"EOF"
{
"pipeline":[
{
"type" : "readers.las",
"filename":"/data/sortme.las"
},
{
"type":"filters.ferry",
"dimensions":"Y = Avg"
},
{
"type" : "filters.programmable",
"function":"moving_average",
"module":"anything",
"script":"$script"
} ]
}
EOF
# This works, but all the " characters get stripped out
pipeline2=$(eval echo $pipeline)
echo $pipeline2
container=$(docker run -it -d -v `pwd`:/data pdal/pdal:1.5)
echo "conainerid: " $container
echo $pipeline | docker exec -i $container pdal pipeline -i STDIN
docker kill $container
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment