stat157 / recent-quakes Goto Github PK
View Code? Open in Web Editor NEWStat 157 Homework 2 due on Monday 2013-10-21 at 11:59pm
Stat 157 Homework 2 due on Monday 2013-10-21 at 11:59pm
We got this error "File "", line unknown
SyntaxError: encoding declaration in Unicode string" when we ran Recent Earthquakes.py. Any ideas why?
After parameterizing the data to account for a specified state, how do I change the plot_data function to account for the change in state. Is the current code fixed to Alaska or is it fluid already?
Within my iPython notebook there is something wrong internally we are unable to figure out.
Within our data file, we are unable to run, restart, and interrupt kernals from loading. The extensive time to run the kernal causes a kernal to fail and 'die.' Within the Virtual Machine we have an error message:
[IPKernalApp] Bad config encountered during initialization:
[IPKernalApp] The 'pylab' trait of an IPKernalApp instance must be any of['tk', 'qt', 'wx', 'gtk', 'osx', 'inline', 'auto'] or None, but a value to u'incline' <type 'unicode'> was specified.
[NotebookApp] Kernal a7684762-05bd-4f46-aa603-9e2c9b0ab01c failed to respond to heartbeat
How can we fix this in order to run our finalized code? This is out of our knowledge base, and a bit too confusing for us.
Our team is still unclear as to what the analyst and the presenter should be doing. "All 4 members of your vertical group should work together no matter what individual roles you have assigned." is not sufficiently clear.
Error with code in 2nd cell:
#d = json.loads(urllib.urlopen(url).read())
#data = pd.DataFrame(d.items())
#data
#opening it locally
d = json.load(open('1.0_week.geojson'))
data = pd.DataFrame(d.items())
data
---------------------------------------------------------------------------
IOError Traceback (most recent call last)
<ipython-input-2-6c51623ddb65> in <module>()
4
5 #opening it locally
----> 6 d = json.load(open('1.0_week.geojson'))
7 data = pd.DataFrame(d.items())
8 data
IOError: [Errno 2] No such file or directory: '1.0_week.geojson'
When I try installing Pandas on the VM, I get an error that says:
"Something wicked happened resolving 'us.archive.ubuntu.com:http' (-11 - System error)
The problem is that you need pandas version 0.12 to use read_json. So first, check whether you have most current version of pandas or not. If not, I recommend you to do following steps.
sudo pip install python-dateutil --upgrade
-this sudo code will install package that you will need for updating pandas
sudo easy_install --upgrade pytz
-this sudo code will install package that you will need for updating pandas
sudo apt-get build-dep python-lxml
-this sudo code will install package that you will need for updating pandas
sudo easy_install --upgrade scipy
-this sudo code will install package that you will need for updating pandas
sudo easy_install --upgrade statsmodels
-this sudo code will install package that you will need for updating pandas
sudo easy_install --upgrade pandas
-this will upgrade your pandas package
Followed all the preliminary setup steps but get this error: ImportError: No module named jinja2
Folium is a Python package we found out in OH today, and my group proceeded to install and play around with it as an alternative to BaseMap for plotting quakes. It allows you to plot the data in as few as 3 lines of code, using Leaflet.js under the hood.
Leaflet is a Javascript library with awesome interactive maps (and it's also mobile-friendly!). Everything is done in Python using Folium, so there's no html/css/javascript involved.
You can take a look at the examples in the docs to get started with Folium. Here's the interactive earthquake map my group made today http://bl.ocks.org/kqdtran/7063887. It's not really polished yet, but I guess it kinda works. The circle's radius is the magnitude of the quake, and if you click on the circle, it should show the information about the earthquake.
If you decide to play around with Folium, keep us all posted how that goes!
Edit: To install Folium, run sudo pip install folium
on the command line!
@reenashah and I are trying to load the JSON data using pandas read_json
function (documented here). the problem is, we can't find the URL for the live earthquake data feed. (to replace the line
url = 'http://earthquake.usgs.gov/earthquakes/catalogs/eqs7day-M1.txt'
with a url that loads in the non-deprecated JSON data.
we've been browsing http://earthquake.usgs.gov/earthquakes/feed/ and clicked on a link labeled "API Documentation" but it leads us to a message about the government shutdown.
has anyone successfully located the URL for the live JSON feed?
Hello,
I posted on the facebook group for visualizers saying that I needed a group yesterday, but no one has responded.
If you're in group and have a spot open, please let me join!
My email is [email protected]
Thanks!
Everything works except the code in the last cell
#For any other states
CI=past_7days[past_7days['Src']=='ci']
box1 = {'llcrnrlon' : -130, 'llcrnrlat' :30, 'urcrnrlon' : -70., 'urcrnrlat' : 50}
plot_quakes(CI, box1)
I'm pretty new to python and I know others are as well.
It would be really helpful if someone could briefly list some steps to curate the data so I can have some direction in my google/stackoverflow searches.
Thanks!
I was able to successfully read the data into python using json.loads, but after printing, the data appear to be in unicode as everything has a u' in front of it: "u'geometry': {u'type': u'Point', u'coordinates'" for example.
This leads to a problem trying to extract elements because I keep getting these types of attribute errors.
AttributeError: 'unicode' object has no attribute 'iteritems'
Has anyone else had this problem? If so, how did you work around it?
How do I open iPython Notebook? Instructions not present.
Code produces an error when run on my virtual machine:
Error 1:
Can't find Cache file. Using online version and creating one instead.
Error 2:
ALASKA
-179.4843
50.0796
-130
69.1603
/usr/lib/pymodules/python2.7/mpl_toolkits/init.py:2: UserWarning: Module dap was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path
import('pkg_resources').declare_namespace(name)
I've opened the file in iPython Notebook but the final cell produces an error.
I installed pandas since I didn't have it previously, as well as the other packages from the preliminary set up steps.
sudo apt-get install python-pandas
I was able to reproduce the iPython Notebook when we read as a csv file, but I'm also having trouble in reading in JSON format. I chose the following feed:
http://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/1.0_week.geojson
But when running the cell with code
import urllib
from pandas import read_json
There was an
ImportError: cannot import name read_json
The instructions say
You should use the pandas JSON parser to read the data instead of the read_csv function in the original code.
but I'm not sure why the error is occurring. Also as I was searching online, there seem to be differences between the urllib and urllib2 packages, and sometimes people have been importing json directly and then using json.loads
import json
Am I using the wrong feed or importing the wrong packages or using the wrong functions?
Thanks!
For example,
csv file have Src variable but it seems JSON file does not have variable called Src,
I thought we have to reproduce same output with current dataset. I wonder which variable in Json is equivalent to Src.
The hard-coded values were removed from the plotting function, but they're stored in a dictionary so you can't generalize to do any other regions than california and alaska.
@lauraccunningham
there's a spreadsheet cache of the data, but no way to cache live data. and no mechanism for extracting cached data from the spreadsheet.
there is also no indication of the magnitude or depth of the quakes in the plotting methods, although depth/mag are all in the group's data frame.
otherwise, the group's exact code is reproducible. just not generalizable.
For the assignment, I understand we all need to individually save our data to run it during the production stages of our homework assignment. Will you be running our code on your own set of cached data as well as ours? or only our cached data?
Regarding Homework-02 due last week, what types of visualizations are you looking for with this assignment? Did you have a preference on how we visualize the data, or do we have free reign as before? If you have a particular example that you think stands out from last week, can you please point us in the right direction so that I can begin thinking about our final project and practice before then.
I wanted to share my ideas about visualization and hopefully get some help on debugging them since our group's data isn't ready yet.
def state_data(state, data):
sdata=data[state in data.location]
return sdata[0:10]
quakes = state_data("California",data)
from mpl_toolkits.basemap import Basemap
def bbox(quakes):
#create a variable called x to create margins
x=50
#calculate quake bounding box from lat,lon
Max_lat=quakes[,1]+x
Min_lat=quakes[,1]+x
Max_long=quakes[,2]+x
Min_long=quakes[,2]+x
centerlat=mean(quakes[,1])
centerlon=mean(quakes[,2])
#create bounded box
b=[]
return b
Am I missing anything up to this point? Does any of it not make sense? Also, how do I synch a python compiler to my sublime text 2? Thank you guys!
From the data feed I am using, the datetime
and region
variables don't completely match in format to the one from the older feed based on the text file. Do we need to change the datetime
format and also remove the distance and direction info from the region
variable?
i.e.
1382220868060
and 92km E of Ciudad Constitucion, Mexico
input parameter names do not match the attribute name in the dataframe:
ex: Longitude in the datafrome, but used dataframe.Lon
also, did not see the points representing the earthquakes...
On the feeds column of
http://earthquake.usgs.gov/earthquakes/feed/v1.0/geojson.php
there are feeds for past hour, past day, past week, past 30 days.
I am using past 30 days because otherwise there aren't very many earthquakes.
Since all the feeds should have the same format, does it even matter which feed we use?
TclError: no display name and no $DISPLAY environment variable]
It also looks like you guys have have hard-coded some things.
It seems like json_read()
only works for a few people. So if that is the case, how do we reproduce the data in class on Tuesday? Those people who can't use json_read()
definitely can't reproduce the code from groups which use that function.
Are we supposed to be analyzing the data as well as visualizing the earthquakes?
I got an error when I import read_json
/usr/local/lib/python2.7/dist-packages/pytz-2013.7-py2.7.egg/pytz/init.py:29: UserWarning: Module dap was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path
from pkg_resources import resource_stream
I wonder why i'm having this error
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.