I will be mentoring a gifted high school student with programming experience for 3 months, and I was hoping to get some feedback here on the most straightforward way for him to complete this goal:
First, an iPad/GoPro camera is used to record a video/still frames of a chemical reaction that result in bubble formation. I.e. at the beginning of the video you would see a blank background, and then later in the video a population of bubbles would exist and grow in size and number.
Then the iPad would be used to analyze and then to plot (# of bubbles) or (total bubble area) versus time.
(we are limiting ourselves to an iPad to test the limits of on demand mobile analytics)
Some strategies I have considered:
1) Use Pythonista with supported matplotlib/numpy modules to analyze images.
Pros: He learns to use Pythonista, the best mobile IDE (he has some experience with this already, I guess his HS has students download this)!
Cons: Without scipy, I'm not sure that the image analysis that we will run across will be entirely possible with matplotlib/numpy. I'm also not sure what limitations we will run into with the pure python modules available in Pythonista.
2) Program this analysis using a python IDE on a PC/mac and then use kivy or some other means to try and compile the code into a stand alone iOS app.
Pros: Access to scipy and other image analysis packages that are already finished. We don't have to reinvent the wheel on particle counting.
Cons: I imagine it might be a nightmare trying to successfully compile from python to a stand alone app... Maybe I'm wrong here?
3) Program the entire thing in Obj C and Swift using X Code.
Pros: He will get experience with an actual app development environment. We might be able to leverage the OpenCV framework.
Cons: The learning curve might be too high to complete within the time frame.
4) Set up a server on a windows PC that uses open source image analysis (ImageJ / Fiji) and use Pythonista to upload the relevant data (image/video) and initiate the off-site analysis.
Pros: Decouples the image processing aspect from the mobile device used.
Cons: Not sure where to look on how to connect a non-jailbroken iPad directly to a PC with bluetooth/WiFi and send it commands to initiate an analysis on the PC and have the PC send back results. This has to be done on an intranet decoupled from a shared WiFi network. Also, having a user connect to multiple wifi nodes would be a usability hassle (having to switch between the go pro and the PC/Raspberry Pi)
Ideally this would result in an ultraportable analysis tool for this specific application of measuring a reaction rate that would simply require the user to record the reaction and press analyze (either within an IDE on the iPad, or a standalone app).
Thanks for any feedback!
I'm wondering if the following is possible:
Can python generate a text file and send it to another app? (basically initiate the 'open in' prompt, or do it automatically, and let me choose which app to open the text file in).
For those interested in what I'm trying to do:
Use 'Get Console' App to collect serial data from equipment that is then copied to iOS clipboard
Use 'Pythonista' App to take this unicode string of data and format it
Open formatted data in 'Data Explorer' which accepts *.txt files
I'm trying to see if going from 2 to 3 is possible through Pythonista.
Thanks so much for your help!
matplotlib + (lightning to serial adapter) + pyserial + equipment = real time data streaming/plotting?
This is that cable: http://redpark.com/lightning-console-cable-l2-rj45v/ , I have used it with get-console for data acquisition. Cool stuff!
Don't answer this if you don't want to, but do you think it will be possible to interact with 3D graphics made by matplotlib?
In my efforts, I ran across the following problem: When I use <code>console.quicklook</code> to preview my generated csv file, the 'open in' button does not function for any apps except for the iOS mail client.
<b>Observations:</b> All the icons appear, but when I touch them, it registers the touch and the menu goes away, but nothing happens (except for the mail client, which properly sends the generated csv as an attachment. The attachment can then be opened in the apps that were listed from safari, but this is a round about way).
The first two lines of the CSV file it is working off of are here:
11-23-13 06:26:18 622.80
11-23-13 06:27:18 623.24</code>
My code (forgive me for this, been working with python for a week :) ) is just attempting to find the time in seconds from the first event and create a new csv file that is formatted differently than the one listed above.
csvfilename = time.strftime("%Y%m%d") + '_data.csv'
with open(csvfilename,'rbU') as csvfile:
reader = csv.reader(csvfile,delimiter='\t') new_date_list =  new_val_list =  for row in reader: #create new lists that will be turned into a csv later new_date_list.append(row) new_val_list.append(row)
update_del =  #list for timedelta objects
for i in range(len(new_date_list)):
date_object = datetime.datetime.strptime(new_date_list[i], '%m-%d-%y %H:%M:%S') #creates a timedelta object (difference between two date objects) deltimeobj = date_object -
`` datetime.datetime.strptime(new_date_list, '%m-%d-%y %H:%M:%S')
#generates a new csv file
with open( time.strftime("%Y%m%d") + 'w'+ '_data.csv','wa') as csvfile:
writer = csv.writer(csvfile, dialect='excel') for i in range(len(new_date_list)): writer.writerow([str(update_del[i]),new_val_list[i]])
out_file_name = time.strftime("%Y%m%d") + 'w' + '_data.csv'
msg = ' Tap "send" icon at right of titlebar to "Open In" another app. '
console.hud_alert(msg, 'success', 3)
This code results in a csv file that can be opened only in the mail client, which I then email to myself, open in safari and then open in 'Graphical' by vernier (for example, many other apps open csv files.)
In this example, Graphical by Vernier (and every other app that supports csv files) shows up as an 'open in' option but when touched does not register any action.
Any thoughts would be appreciated :)
As I understand it numpy is not currently possible on Pythonista. Only modules entirely written in Python (it seems like you know this, but just saying for those lurking). Numpy has some C/Fortran behind it, so requires a bit of effort to get it working.
One developer has been working on Numpy and has released it under the PyNum app. I did run the pipista code to grab a python module, but it didn't untar. I'm using the newest iPad/OS as well.
ccc, thank you! It works perfectly, and was very useful for me to go through as I start Python.
I wanted to also note for anyone that happens to come across this discussion through a search that another App I have found useful for data plotting that works better than Data Explorer currently is 'Graphical' by Vernier. If you use ccc's code to generate a csv instead of a text file, you can open in Vernier and plot it quite easily and select regions of the plot to do a lot of analysis. (now I just have to play with exactly how Vernier wants the data formatted to convert my serial port data to something workable).
Also the Graphical app has some fun applications where you can use the built in iPad sensors to record acceleration for example. I recorded my flight takeoff discretely to see how fast the plane was accelerating. :)
Thanks for your replies!
I do have an account on DropBox, so that might be a solution. The reason I am hesitant is that it isn't officially supported by IT.
You correctly found the data analytics software, it is the first link you provided. It is an iOS app.
Okay, so console.quicklook pointing to a txt file could let me open in the iOS analytics app.
I wouldn't have to transfer the data if Pythonista had numpy (one iOS developer has managed this, the pynum app) and matplotlib (no one has done this), but that is a lot to ask. I would say though, that Pythonista has a beautiful interface, and if it could implement those modules to allow scientific data analysis, a lot of people would be happy (and as an in-app purchase, you could go away w/ lots of $ to support even more development :) ).