This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# File Transfer for Pythonista | |
# ============================ | |
# This script allows you to transfer Python files from | |
# and to Pythonista via local Wifi. | |
# It starts a basic HTTP server that you can access | |
# as a web page from your browser. | |
# When you upload a file that already exists, it is | |
# renamed automatically. | |
# From Pythonista's settings, you can add this script | |
# to the actions menu of the editor for quick access. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data['LAT'] = pd.Series([str(round(value,9)) for value in data.lat], index=data.index) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reversing a dictionary, key <-> value | |
# but only this work when values are hashable | |
# and there are no duplicate values. | |
# credits to: http://stackoverflow.com/a/19165996 | |
p = dict(zip(i.values(),i.keys())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from datetime import datetime | |
# Suppose you have a list of dates that you want to rearrange and group by year and month | |
date_list = ['2002-10-31', '2002-11-12', '2002-11-13', '2003-01-26', '2003-02-01', '2003-02-02', '2003-02-04', '2003-02-07', | |
'2003-02-09', '2003-02-16', '2003-02-18', '2003-02-27', '2003-03-02', '2003-03-04', '2003-03-05', '2003-03-10', '2003-03-12', | |
'2003-03-13', '2003-04-15', '2003-04-16', '2003-11-21', '2003-11-24', '2004-01-29', '2004-01-30', '2004-01-31', '2004-02-01', | |
'2004-02-02', '2004-02-03', '2004-02-04', '2004-02-05'] | |
# You can convert it first as an isoDate | |
isoDates = [datetime.strptime(d, "%Y-%m-%d") for d in date_list] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Examples to parse a date | |
from datetime import datetime | |
def parser(string2parse): | |
return datetime.strptime(string2parse, "%d/%m/%Y") | |
H3 = pd.read_csv(os.path.join(dirname,filename),sep="\t") | |
# Alternative (1) | |
H3["isoDate"] = [parser(d) for d in H3.Date] | |
# or | |
# Alternative (2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# /etc/sysctl.conf - Configuration file for setting system variables | |
# See /etc/sysctl.d/ for additional system variables. | |
# See sysctl.conf (5) for information. | |
# | |
#kernel.domainname = example.com | |
# Uncomment the following to stop low-level messages on console | |
#kernel.printk = 3 4 1 3 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
__credits__ = ["José M. Beltrán"] | |
__license__ = "GPL-3.0" | |
__created_on__ = ["2014-10-15"] | |
def create_pin_files(data_frame, outdir): | |
""" | |
Batch process the creation of BEAM-VISAT (http://www.brockmann-consult.de/cms/web/beam/) pin files. | |
Outputs a "pin_sampling_date_batched.placemark" file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Modified from: http://stackoverflow.com/questions/14114610/finding-centre-of-a-polygon-using-limited-data | |
See also: http://en.wikipedia.org/wiki/Centroid#Centroid_of_polygon | |
NOTE: All the following geolocations calculations assumed that | |
the distance from each position is short, i.e. that can be considered to over a flat surface. | |
Otherwise, converting to spherical coordinates needs to be implemented. | |
""" |