Numpy quick stats
import numpy as np
dat=[some array of numbers]
np.percentile(dat,10)
np.percentile(dat, 90)
np.mean(dat)
np.median(dat)
np.std(dat)


⣠Chile in a Photography âŁ

romaâ
One Nice Bug Per Day

Discoholic đŞŠ
Keni
Show & Tell
Cosmic Funnies
will byers stan first human second
Claire Keane
$LAYYYTER

ellievsbear
The Bowery Presents

izzy's playlists!

oozey mess
noise dept.
trying on a metaphor
Mike Driver

Jar Jar Binks Fan Club
seen from Indonesia

seen from France
seen from Colombia
seen from Bangladesh
seen from Brazil

seen from Netherlands
seen from France
seen from Uruguay

seen from Malaysia
seen from Brazil

seen from Italy
seen from France
seen from Chile
seen from Thailand

seen from TĂźrkiye
seen from Russia
seen from Honduras
seen from Iraq
seen from Venezuela

seen from India
@recordcodes-blog
Numpy quick stats
import numpy as np
dat=[some array of numbers]
np.percentile(dat,10)
np.percentile(dat, 90)
np.mean(dat)
np.median(dat)
np.std(dat)

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch ⢠No registration required ⢠HD streaming
Compiling C programs
To compile a C or program (extension .c), use the commandÂ
gcc programname.c
Use the -o option to specify the output name
gcc -o newname programname.c
If the extension is .cpp, then it is a C++ program and you can use
g++ programname.cpp
The result by default is a script called âa.outâ. You can run a.out directly.
Numpy loadtxt
All parameters are
numpy.loadtxt(fname, dtype=<type 'float'>, comments='#', delimiter=None, converters=None, skiprows=0, usecols=None, unpack=False, ndmin=0)
fname is the filename â./sample.txtâ), where the text needs to be columns of the same length, ie no missing values (for missing values look into genfromtxt)
dtype is the data type, which is automatically set to floating numbers (includes decimals). To download the list as a string, you would type in dtype=âstrâ
AWK print rounded numbers
To get the format XXX.XX for a column of numbers, try:
awk â{printf â%3.2f\nâ, $1}â
the \n indicates a new line
AWK printing single and double quotes
for the double quote â awk âBEGIN{print â\ââ}â
for the single quote â awk âBEGIN{print â\x27âł}â

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch ⢠No registration required ⢠HD streaming
Specify field separator for sort in Unix
surprisingly easy :) and listed in the manual for âsortâ command (>> man sort)
as an example, say you have a commas as the FS. to sort, use the option
sort --field-separator=,
that is a double dash - -
Remove empty files
find . -type f -empty -delete
Using argparse
One use of argparse in Python that I use often is writing a script that takes an input from the command line. This way, you can run the script iteratively over multiple files.Â
import argparse parser = argparse.ArgumentParser() parser.add_argument(â--infâ) args = parser.parse_args() data = np.loadtxt(args.inf)
Python Imports
Some good/common things to import on python
import numpy as np import matplotlib as mpl mpl.use(âAggâ) from scipy import stats from matplotlib import pyplot as plt import argparse
Tranpose matrix with Python and Numpy
Given a text file that formed like a complete matrix, you can use python and numpy to get the transpose of it as needed by using the following lines:
import numpy as np origdata=np.loadtxt(â./datafileâ) transposedata=np.array([list(i) for i in zip(*origdata)])

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch ⢠No registration required ⢠HD streaming
Ipython
use the command to bring up the ipython gui
ipython notebook
and use the command to see the figure without on the same page of results
matplotlib inline
Changing the color bar for gmt plot
use the commandÂ
makecpt -T1/3/0.5 -Z > ppp.cpt
to create a color bar from value of 1 to value of 3 in 0.5 intervals stored in a file called ppp.cpt. This ppp.cpt file is used in the script that makes the plot within the line
cpt=âppp.cptâ
An example (as of the day this is posted) is in the space I have on hydra, I have a file called .plot.temp.scr -- it is a script that was originally used to create a plot of temperature. I use the command
./plt.temp.scr precip.climatology
to create a plot called precip.climatology.png
Suppressing and saving a figure in python
Useful for when figures/graphics are not supported and you want to save the figure directly without it popping up
import matplotlib as mpl import matplotlib.pyplot as plt mpl.use(âAggâ)
<<code>>
plt.savefig(â./title.pngâ)
using AWK to find min, max
Use awk to find the minimum and maximum value of column one in some file âdata.txtâ
awk â{if(min==ââ){min=max=$1};if($1>max){max=$1};if($1<min){min=$1}}END{print min, max}â data.txt