Chauffage iPad version
I started working on the iPad-version. It turns out to be much more work than I initially thought it would be. My detail view is quite complicated and requires a lot of dedicated TableCellViews. If I want to support landscape, I even need to double those. As many CellViews have TextFields in them, the delegate TextField method obtained a rather complex switch-statement (as some other methods as well).
Some issues that I encountered:
- Toolbar not visible - for the detail view, I used a standard UITableViewController object on the storyboard. Unfortunately I was not able to add toolbars to the corresponding scene. I could have put a UINavagationController before the UITableViewController, however that resulted in other errors, which seemed difficult to solve. So I reverted to a standard UIViewController and added all the necessary objects. That needed some more wiring to do, but all works;
- Initialisation in portrait orientation - I have a problem with initialisation, when the iPad is in portrait orientation. The necessary data is then not set up as should. Problem is that the master splitView is not presented on screen and thus the initialisation is not done. It might be necessary to do this in awakeFromNib;
- Enabling a button based on selected row - I will enable a button based on whether a row is selected. But where should I disable it?
- Next/Previous - I had the idea of adding a next/previous button on the detail splitView. However what next and previous is, is only known by the masterSplitView. This is however off-screen. I opted for a protocol, so that the current view is updated with a new client. I disable the next/previous button, when there is no longer something available, which turned out to be a bit fiddly to take care of the edges. I decided to change my initial implementation. Things are now a lot simpler: the less code, the more stable;
- reloadData does not display - I have the situation where I can change the entire contents of a tableView which is on display. So no pass through ViewWillAppear or ViewDidAppear. So I should force an update through [tableView reloadData]. Well that method is indeed called and it calls in turn cellForRowAtIndexPath: with the correct data, but still nothing happens. Not figures this one out yet;
Chauffage app
I started working on my first real app, called Chauffage. This app should help us with our billing. It helps calculating the heating cost of our gites. This app should be fairly straightforward and involves Core Data and TableViews. I need to input various types of data (string, integers, floats, dates and a pick list). So it gives me a chance to dive a bit deeper into things. It should however be ready in a few days.
However I did come across a few issues and errors of mine that took more than average time to solve:
- White startup screen - the first time I stared the app, nothing happened. I just got a white screen. I discovered that even my first scene was not called. The I had the good idea to look in the app delegate. And by comparing with earlier apps, I discovered that there was some code that should not be there. Indeed deleting that code, did start my application. I guess that I started out with the wrong template;
- Database not opened - I had trouble accessing the database. After looking into the flow more deeply, I discover that the database was not opened yet, when I tried to access it. I just was to quick. So now I put the access part in the completion handler part;
- Singleton not initialised - at some stage I noticed that my context was not saved. I was smart enough to print an error in case. The error was however NULL. After looking around on Internet, I found that the issue was the context was nil, so it was not initialised. After following the flow around the singleton, I saw that I forgot to add this global database variable to the singleton;
- Inline editing - I wanted to add the possibility of inline editing of a tableview cell. After a lot of digging I decided to create a subclass of a UITableViewCell. I configured that cell with an UILabel and a UITextField properties. Then I created the corresponding view. In the tableview:cellForRowAtIndexPath:, I created a cell based this subclass and view (need to load the corresponding nib-file). The cell-properties allow me to fill in the label and the placeholder for the textField. And most importantly I set a textField.tag based on the row of the tableView. The class with the tableView is also the delegate for the textField. In the delegate method didFinishEditing I check the tag to find out the row of the tableView, so I can update the right properties;
- NSMananagedDocumentContext changed - a tried to insert a new Managed Object in the database, but was struck with an error without warning code. In the debugger I found an method where the bug roughly occurred. Searching on the Internet, I found that the problem was that the context changed. Next step was to find out where that happened in my code. It turned out that I re-read my document-files and was thus assigned with a new context. Getting rid of that solved the issue;
- Defaults Bundle not used - I created a bundle to hold the default values, which can be changed through Apple’s Preferences app. Took me a while to find the correct and understandable directions. I though I could subsequently access this bundle through the standardUserDefaults method. However that was not the case. One has to setup things before in the application delegate method AppDidFinishLoading (or something like that). Apple has a nice example, which I could use;
- Localisation literals - I did a localisation of all the texts occurring in the app. I thought I would be smart and use #define to create all the texts. Especially as the same text occurs now and then. However the ‘gentexts’ macro does not like literals. So I had to change all again.
- Button title localisation - I thought being smart by creating all the button titles in the application and not the interface. I adapted the size of the button to accommodate the length of the titles. However this does not work well. The size of the text-button label does not seem to be adapted, so text is still cut. Furthermore after pressing a button there is a relic of the title I put in the scene. Turns out that I have to set the title from code for all possible four states;
- Read/Write mismatch - I seem to have a problem reading and writing. I write some changes to disk and after that retrieve the data again. It seems however that the ‘after’ happens after the retrieving, so I do not see the changes. However when I restart the app the changes are there. I added the CoreData controller used in the cs193p course, which helped a bit. The FetchedResultsController has to detect changes. However it does not seem to see all changes. Need to do some more testing.
I am about to wrap this phase up. The app is working. Now I can deploy privately and do some testing in practice.
CS193p wrapping up
I am putting the last touches to assignment 6. There are only a few courses left, so it is slowly time to wrap things up. I started looking at these other courses.
- Course 16 - discusses alert and action sheets, which I used already. It explains animation a bit more. Not sure I will need that, but it might spice up some apps. The section on the camera and NSAcceleration was interesting. I will use that;
- Course 17&18; - interesting introduction to the iCould. I guess I could use this stuff. have to look at the course again though.
- AVFoundation - had a look at this extra course. Looks interesting. I might have to use it for what I have in mind;
- Smule - the presentation by Ge Wang was very nice. Not many things in it that I will use though. However their openLibrary might contain some interesting things;
- OpenGLES - had a look at this presentation. Interesting, but for the moment I do not need it. When I do, it might be worthwhile to find an OpenGLES course;
CS193p Assignment 6
Again I record my progress on this assignment in this post. For this assignment one has to watch several courses. These are basically courses after lecture 11 (Core Location / MapKit):
- Lecture 12 - a lecture on persistence. Not sure if we’ll really need this, as we will work with Core Data. Furthermore several file system stuff taken from this lecture has already been used in Assignment 5;
- Lecture 13 - a lecture on Core Data. Looks complicated, but if you know SQL it is OK. This lecture also discusses notification and categories;
- Lecture 14 - a demo of Core Data. Was nice, have to use a lot;
- Lecture 15 - Watched this lecture. There might some lesson in it for the extra’s of this assignment (textField);
- Lecture 16 - Did not see anything that I might need.
The assignment 6 application is taking shape. I created a new branch to do this work in.
- Storyboard - all the necessary scenes and segues have been created. I added scenes for:the list of vacations, a vacation (static one), the itinerary, the tags and photos for the itinerary and photos for the tags;
- Segue start point - I am still confused where I should start the segue: from the prototype cell or the tableview object? Either one does work. However when I use the cell as start point, the prepareForSegue: method is not called at the right moment;
- VacationTVC - this one is really simple. It only shows the two possible sorting possibilities for vacations. Nearly everything can be setup in the storyboard. The only code I created was to set the title of the navigationItem dynamically. And I pass the vacation on to the next TVC. I had hoped to do this TVC with segue’s from each cell. But that did not seem to work right. So again I started from the TVC object and added a switch to didSelectRowAtIndexPath:;
- PhotoURL - the information stored on each photo in a vacation is insufficient to recover the real Flickr Photo dictionary. One could add all the other retrieved info, but is that worthwhile? So I added a new interface to the PhotoVC setPhotoUrl. This can now be used to retrieve the photo there. But I also had to make an inverse photo-dictionary method. This allowed me to pass the title of the photo to the PhotoVC with the existing interface. I am not happy with this approach. I might redefine the PhotoVC interface to just the photo_title and the photo_url. I think I do not use any other info on the photo. Or I should look into other approaches (delegates?);
- Tags - I created a new entity Tag, which stores all found tags. The Tag has a n:m relationship with Photo. So a tag can point to multiple photo’s and a photo can point to multiple tags. I set both in their category methods. The tag-string taken from a photo is split in multiple tags using a space as delimiter. Still tags seem very messy, so I might clean up a bit more;
- Database creation error - I made an error in creating the database, which consequently resulted in all kind of errors in the predicate. It took me a while to find. I must be more careful;
- n:m relationship - I created an n:m relationship and wanted to use the inverse relationship in the predicate. when fetching the entity Photos, I used the Tag:hasPhotos attribute like “SELF IN %@”, tag.hasphotos. This will retrieve the given set (tag.hasPhotos) of photos;
- Vacation class - I wonder whether I need to introduce a vacation (data) class. In this class all initial file handling can be done. Now I have copies of this in four TVC’s. The same goes for a Vacations Data Class, but here there is no doubling of code. I did create a Vacation-class, which is passed on between controllers;
- Model classes - I do not know which model classes I need for photo’s. In assignment 5 I used just the dictionary provided by the FlickrFetcher. In this assignment I created another class Photo for the same thing. The problem is that these two model classes meet each other and need to exchange data. What I really need is a single class that holds all the data and either gets it from core data or from Flickr. I do not yet know how to solve this;
- Threading - I have some trouble with threads. I need the application to wait on a finished process, which seems to take place in a separate thread. Not sure how to solve that yet. It seems I do not quite understand how things work. When I call performSegue: it seems to continue with the method in which it was called. I thought that it would do first the performSegue: and than come back to the calling method. I expected something totally synchronous. That does not seem to be the case. So at some stage it does do this modal segue and when I select something, it calls the delegate and I might have to do my stuff there. In case of a cancel, probably viewDidLoad is called again? Need to check. Solved by putting things at the right place;
- NSPersistentDataStore - I get an error that there is not such a store. Not sure what is happening and what it is in the first place. Turns out that the document was closed in the mean time. After opening it again I was able to write to it. The closing happened somewhere along the lines. I do not know when this happens. In any case I must now check always the closedStatus before explicitly writing. And I should explicitly write after each change to the database, as it might get into an unable state otherwise. Seems a bit cumbersome, as I would like to minimise disk-access;
- Incomplete photo description - it seems I have an incomplete photo description somewhere, as the wrong thing is written to disk. Still need to figure this out with a lot of NSLog’s (solved);
- Singleton - I solved my earlier problem with the DataStore through a singleton. In fact later I found out that in the hints something similar is suggested. The code is now a lot cleaner. I could throw a lot away. I will experiment with throwing even more away;
- New Vacation - This is the first of the extra tasks. I implemented the first steps in creating a new vacation. It is created, but I still have a flow problem. I am not able to select it, after creation. I am not sure where I should update the tableView;
- Empty entities - The Tag and the Place entity should allows refer to at least one photo. Empty tags and places should not be allowed. Normally when I create a photo, the corresponding Place and Tags entities are created or extended. However what happens when I delete a photo? I am left with empty Tags and Places. How can I prevent that? I added code to check this happening, but I have a feeling that I can solve it in another manner, which is much more lean (do I delete the object in the right way? have I set the entity attributes right?);
- Closed documents - I am not sure how often I should check whether a document is open or not. Now I do it before each fetch. Seems a bit to much. Doing it less would make the code much more lean;
- Top photo places - when I retrieve the top photo’s, I do not get the place name. How can I retrieve the corresponding place names? I guess I need to add something to FlickrFetcher;
- Storing top photos - in assignment 5 it was demanded to store the top photos in a defaults database. I did not bother to do that. However it might add an added complexity, so I would implement this after all. Turned out to be not so difficult (and interesting). However I had an extra complexity due to an inheritance issue;
- Itinerary by date - I should order the itinerary places by date added. Need to extend the data model for this. Will implement this as it gives me a little bit of experience with date and time (not so much);
- Re-ordering - the last thing that I need to do is supporting reordering places in an Itinerary. For that I created an entity Itinerary. This entity has a many link with Place, which is ordered. And each Place is part of an Itinerary. I each Vacation there is only one Itinerary. This Itinerary has the same name as the Vacation. In the corresponding tableView I retrieve all the itineraries (just 1) and use the relation to find all the. corresponding ordered Places. Moving a row in the table should redefine ordering of these places. I got it working thanks to code I found on the Internet;
- Wrapping up - there are still some bugs in the application and it does need some clean-up to remove old code. I could still experiment a bit. However I prefer to start with my own application and dive a bit deeper into that one;
CS193p Assignment 5
After watching lecture 11 and 12, I started working on this assignment. The lecture on version control is also useful, although I had already found out most things.
- Threading - I created 4 four threads for each time I access Flickr. Not sure if it is working though. I see that the threads are created. I can use the interface while the data is loading. So all looks good;
- Concurrent loads - I noticed that I could select another image during a load, which will turn into another image loading. Does not look very good, so I limit myself to onen load at the time. To detect a load I check whether the spinner exists. Probably not a good way to do this;
- Spinner - I copied the Spinner idea from the Lecture, but nothing happens. Do not know why. I changed the TabBarItemes.title to a recognizable text and NSLogged these titles. The titles do change as they should, but it is just the interface that does not update. I figured out the problem. I did put back the original spinner at the wrong place. Now I do it inside the main thread, within the data fetch thread. All seems OK;
- Caching - I figured out how to do the caching. I created a separate class to do all the lifting. I created methods to check the existence of an image, to put it in the cache and to retrieve it. Still need to see how I can do pruning based on size of the cache and oldness of images. The caching also introduced a problem (crash) with changing the titles of the photo view. An assumption seems to go wrong. Also need to see if I can streamline my fetch photo code and how the threading is now working. Should I put the threading inside the method or not?;
- Pruning - the pruning part of caching is working. Had to discover a lot about paths, file attributes and sorting. I put all the writing and pruning in a separate thread.
- Caching crash - the caching crash has been solved. It had nothing to do with caching. It turns out I deleted to often elements from the bar at the top, beyond what was there.
- View switch - I must switch between a list view and a map view of photo’s. I can implement that in various ways, but I do not know the best way yet. It is easy to go one way, but how to switch back? How to create something really symmetric? For the moment I just added a view above the table view and put a button in it. This button provokes a segue to a mapViewController;
- Segue’s - I had a fight with the segue, which should show the mapViewController scene. I think the problem was that I loaded this segue twice. You either define it from the button to the scene and do nothing in the mapViewController. Or you make the segue from the calling ViewController to the Scene and define in a button action that it should be called. But not both!!!
- Map - the MapView controller was easily implemented if you follow the corresponding course. This included the small (not really useful) thumbnails on the callout;
- MapRegion - I calculated the size and location of the Map by traversing all locations, calculating the minimum and maximum latitude and longitude. The average of these gives the center. The minimum and maximum can be used to define the span. This span includes a factor to have a nice area around the pins;
- Inheritance - this application can use a lot of inheritance, but I have not yet figured out how I should use it. But if I want to make maps coming from the places table and the favorite photo table, then I must solve this. I think I will create a sub-class for the MapVC, so that I can disallow asking for images, although this might be solvable through returning a nil as image. And I will create a single class for all tableViewControllers. I then only need to implement a different Flickr retrieve algorithm for each specific tableView. Well at least that is my theory for now;
- Error - I encountered a very strange error: “Couldn’t register com.topPlaces.debug with the bootstrap server. Error: unknown error code. This generally means that another instance of this process was already running or is hung in the debugger.Program received signal: “SIGABRT”.” After searching on Internet I discovered that some zombie processes are running, which can only be killed by restarting the machine. That helped;
- Inheritance scheme - I implemented my inheritance scheme for the tableViewControllers. Also the placeTableViewController is part of this scheme. Thus I have now one MapViewDelegate;
- Place annotations - I create a separate class in order to calculate the annotations for places. I implemented this just like the photo annotations. However a place consists of three parts (city, region and country). I still need to add the third part. Advantage is that the TableViewController does not know anything anymore of the Flickr data keys;
- Flickr retrieval - One of the main difference between the three tableViewController classes is the call to retrieve the data. I do not know how can reduce the code any further with inheritance;
- Accesory action - if I press the accessory button on a pin, I need to call different methods depending on the data. Or have the delegate do different things. It seems I can not redefine the delegate method in a chiled. So I am a bit lost here. Update: I forgot to set the delegate and now all is well;
- Place annotations 2 - I solved this issue by subclassing the PhotoAnnotations class and redefining the methods. The third part was added to the parent class. This part took a long time, as I did not quite understand the MKAnnotation-thing;
- MapViewType - changing the mapViewTypes was super simple;
- Title issue I solved the title issues. Each screen now has a nice title, which is based on the current an previous viewController;
- iPad/iPod - things are still working on the iPad and iPod;
- Resiliency I am not sure whether the app is resilient enough. I encountered several problems with the Flickr API, which I guard against. However there might be more to do;
- Caching problem - I suspected a caching problem. The system retrieved the same photo each time after switching to another one. I thought that the caching did not work. However it turned out that the cache was to small (or image to big) to keep it in the cache all the time. So a 10 MB cache is on the small side. I could also restart the app to remove all kinds of other stuff;
Seems that I am ready to move onto the next assignment.
CS193p Github
I created a github account to store my cs193p assignment results.
My first repository Calculator is to the store all the work on the calculator. This covers assignment 1 to 3.
I intend to commit all small changes to the application closely following the parts of the assignment and documenting the hints from the assignment and the courses. Unfortunately I have to redo my assignements again to create the required commits.
CS193p Delegation concepts
Delegation is a rather difficult concept to understand. In order to get a better idea what it is I made a drawing.
Suppose we have three object: a square, a circle and a pentagram. The square has four white holes in itself (an oval, a 4-pointer star (not quite white), a 5-pointed star and a hexagram). It announces to the world that another object can fill these holes (the lines protruding the square). In fact it needs two other objects: one for the blue holes and one for the red holes.
The circle object announces that it will help the square object with its blue holes. And the pentagram object says it will help with the red holes. Thus the circle object fills the blue oval hole of the square object. And the pentagram object fills the red pentagram hole and the 5-pointed star hole of the square object. The four pointed star has not been filled as it was optional (not quite white).
With this it is possible to explain the various delegation concepts:
- delegator - the square object is the object that delegates;
- delegatee - the round and the pentagram objects adopt the delegation responsibilities;
- delegate property - the square wants to know who his delegatees are. This is specified in his delegator properties (the two extrusions on the square). One of the extrusions is filled by the circle, the other by the pentagram;
- protocol- the set of holes in a specific colour define a protocol. The small square on the edge of the circles says that the circle adopts the blue protocol as defined by the square. The same goes for the red protocol on the pentagram;
These leads to the five steps defined in course 7(?). Two steps are definition and three steps are adoption:
- Protocol - define the methods for a protocol;
- Delegator - define who needs to delegator a protocol;
- Adoption - a class (delegatee) should declare it adopts a certain protocol;
- Implementation - the delegatee should implement the methods required in the protocol by the delegator;
- delegator properties - the delegator properties that point to its delegatees should be set;
CS193p Assignment 4
I started working on Assignment 4 of the CS193 fall 2011 course.
- Flickr API - I got the Flickr API working and am able to access the top locations and photos per locations. I did have a bit of trouble figuring out the data structure that Flickr is giving. I got mixed up in Array’s and Dictionaries. Why does the flickrFetch API give an NSArray and not an NSDictionary?
- Storyboard - I had a lot of trouble getting a good storyboard. However after seeing Lecture 10, I decided to delete everything and restart from scratch. Just as Paul Hegarty did during the Lecture. And then everything went pretty smooth;
- Place Photolist - Getting the Photlist for a specifc place working got me bogged down for a while. Until I realised that I did not check the Segue identifier in the right way. I used ‘==’ and not ‘isEqual:’. After that it worked well;
- Description dictionary - I was not able to get the information on the description through the ‘description._content’-key. So I had to take the long way to retrieve it;
- Title and description length - the lenghts of these two items is much longer than the screen width. What is the best way to present them?
- Photo location list segue - I do not understand how this segue works. You do not have to set something up. Just add the segue to a table view controller seem to be enough to have it respond to a row selection? From where should I setup the segue? The window? the table? the cell? The window as anchor works with a performSegue: in didSelectRow:, but why?)
- Titles - I have been playing with the window titles a bit in order to display city name and or photo title. I would like to limit the number of characters and append a ‘...’ at the end. If I use a minimum size that is to large I get an error message. So I must take into account the maximum allowed length. Still have to work on that;
- Photo display - I got the photo displaying working, but I was not able to set it to fill with UIContentMode. It turns out that I implemented conflicting procedures: in storyboard it was set to AutoFill, but in the methods I un-implemented this fill by setting the image size and/or frame;
- iPad - I had to rewatch the course on the iPad to see how it worked again. Setting up the storyboard was reasonable straightforward. I had to remember to setup the photoViewController as detailedView. And to not use segue to present photo’s. It seems to be working. I have now to address the details;
- Generic TabBarViewController - just like in the course I created a generic TabBarViewController, in which I implemented the DetailedSplitViewController methods. I get the impression from the assignment that there is also another solution;
- Subclassing - I created a subclass for showing a list of photos: one for the most popular and one for a single place;
- Sections - I implement the extra requirement: sections in the Places-list. I had a hard getting my head around it, fighting with arrays and dictionaries. My final approach was to enumerate all the places I had retrieved, extracted the country (careful here). Each country was added to a dictionary and each place an array in that dictionary. As the tableview does not like dictionaries, I had to convert it back to an array by enumerating over the keys. I added the name of the country as the title of a section. The provence is now the detail;
- NSRange - To find the country from a place, I had to extract the last element in the location. Normally a location consists of three elements divided by comma’s. So I use rangeOfString: to find the location of the comma. However when there is no comma, I get a crazy number. So I can not trust it. However the length is then 0, so I can use this to see whether there is a comma in a string (anyway I no longer use this approach, see next item);
- Location parts - As noted a location can consist of three parts. NSString has a method (componentsSeperatedByString:) to extract these parts given a delimiter @”,”. This method provides an array. The first part will be the name of the city and the last part the name of the country. And if there are only two parts, it does not matter. I got these working after listening to lecture 11 (?). I needed to use the method ValueForKeyPath:;
- Reset contentMode - after loading an image one has to reset the contentMode for the imageView and scrollView, otherwise parts of the image can be cut off. I used a contentMode which fits the image to the size of the view. Also the zoomFactor must be reset to 1;
- Image in TabBar - I would like to suppress the tabbar when showing the image, but have not yet found out how;
CS193p Post Assignment 3 thoughts
I finished assignment 3 now, apart from the content scaling thing.
In course 9 the TableViewController was introduced. I added the instructions as given during the course. It all worked like a charm. I did however a few things a bit different: all buttons were added to the toolbar in the iPad storyboard.
Paul Hegarty was not able to all the relevant things in the course, so extra code was posted on the website. I folded all the posted code into my code. I used a slightly different approach to the iPhone storyboard: I added a toolbar at the bottom of the GraphView and put the formula, switch and add to favorites in there.
I am however left with one problem: the swipe gesture does not work. I still have to find a way to debug this. At the moment I am lost. It seems that the swipe-gesture is not recognized.
CS193p fall 2011 resources
This post gathers interesting resources I found for the fall 2011 course.
The official material can be found on the course website at Stanford and on iTunesU. These lectures are based on Xcode 4 and iOS 5, so the older solutions are no longer applicable. There can be some help found in a corresponding Google Group.
There are multiple people that I are following the course:
I found various solutions on the web, which work as inspiration. You can find my solutions on Github.
Assignment 1 (Simple Calculator)
Assignment 2 (Programmable Calculator):
- Geekapproach - looks like an interesting solution to evaluate the expression;
- maxkostow - combined code for assignment 1-3;
Assignment 3 (Graphing Calculator):
- maxkostow - combined code for assignment 1-3;
- Jeffrey Lam - solution does not seem to use a datasource;
- Hung - solution for assignment 1-3;
CS193p Assignment 2 thoughts
In this post I gather some thoughts on the assignment 2:
- protocols - for the iPad application to work one has to define a protocol in a separate-file. I just followed the directions in the lecture, but I am still at a loss how this works;
- error handling - in one of the earlier assignments one had to implement some error handling (division by zero). This should also propagate to the Graphing Calculator, which I did not implement;
- Points vs. pixels - the assignment asks to use this conversion in order to have the app working on retina displays. So I added this scale factor and thus doubled the number of calculations. However it does not seem to make any difference. So I am lost here;
- drawing mode - I had some problems implementing the drawing mode (line vs points). I added a segmented switch to the iPhone and iPad GraphController views. These call a method drawingModeChanged in the GraphController, which in turn changes the corresponding instance variable in Graph. But I was not sure in what method to set the drawing mode. After some experimenting I found the right one (tell you later which one);
- Xcode crash - I experienced a heavy Xcode crash. The application would no longer star with my project. I tried to use Time Machine to get a valid version back, but that did not work. So I recreated the project and pulled in the old files one by one. I was able to pull them all in without any problems. So I guess one of the project-files got corrupted;
- Profile - the final part of this assignment involved optimizing the code for the pinching gesture. I did not finish this, as it seemed to involved a lot of rewriting. I guess that one has to use a CGContextScaleCTM to change the scale;
IOS programming
And again I started learning IOS-programming. The last time I did finish the book by LaMarche for beginners. However I did not feel confident enough to work on my own. I started with the CS193p course that was then available, but got bogged down in mismatching courses and materials.
So a new year seem to be a good start to begin. I found out that in the mean time Xcode was heavily changed and IOS moved to version 5. This implied that I really had to start from the beginning. I am now up to course 7 and finished assignment 2.
Bundle time
It seems that it is the time of the year for all sorts of bundles.
The bundle of Productive Macs looks at productivity apps, such as Fantasical, BusyCal, Home Inventory, NotBook, Folder X, LaunchBar, Cashculator and Tags. They offer also some prize. Anyway the bundle is not for me, I have already enough related apps. I like the prizes though, such as Hype.
The MacUpdate bundle seems more interesting with TechTool Pro, IconBox, TotalFinder, Postbox 3, FontPack pro Master, Labels&Adresses;, Mac DVDRipper Pro 3, Back in Focus, NeverWinter Nights, Hear, iClip 5 and FolderSynchronizer. I like TechTool as I have not really something comparable. TotalFinder looks interesting. A DVDRipper useful (Handbrake?). Back in Focus and iClip (have an old version).
Effect of eccentricity

Simultaneous fitting two transits of an eclipsing binary is not evident. It is not allways clear how the various parameters interact. For SPH10003247 I used this approach:
- start fitting the secondary (shallowest) transit by changing the relative luminosity of the stars. A luminosity ratio of 0.55 matches the secondary transit. And also the primary transit can be matched (black lines in figure). A further increase (say 0.52) of the luminosity difference will make the secondary transit to shallow. A decrease (0.6) will make the primary transit not deep enough.
- A shallow secondary transit can also be produced by having a size difference between the two stars. Increasing the size of the secondary star to 1.26, will produce the right secondary depth. However this will not produce the right depth of the primary transit. The advantage of a size ratio is also that we will have a flat transit as we have in the data.
- Using a luminosity difference seems to be the preferred explanation. The next thing we need to explain is the shape of the bottom of the transits. Unfortunately any change to the size ratio will make the depths shallower, so a correction to the luminosity ratio must be applied as well. Thus we need to increase the size of the secondary star whilst decreasing the luminosity ratio. Unfortunately at a size ratio of 1.15 and brightness ratio of 0.72, the primary transit is no longer deep enough.
- It is also possible to move in the other direction: decreasing size ratio and increasing the luminosity ratio. It is not possible to go below a luminosity ratio of 0.52. At this ratio the secondary star is fully occulted by the primary, and thus the depth of the secondary transit defines this luminosity ratio.
- In order to explain the transits, I need to work with a third parameter: the linear limb brightening coefficient. Standard this is set at 0.6, but in practive it can vary wildly depending on the star. By decreasing this factor to 0, I can increase the lumiosity ratio to 0.46 and decrease the size ratio to 0.88. This still does not explain the observations: the secondary transit is to narrow and the primary transit is to shallow. The size ratio must be as small has 0.77 to explain the width of the secondary transit (red lines in figure).
Thus my current model does not work to explain these observations. I need to have other parameters that I can tune. There seems to be one assumption to many in my model.
This eclipsing binary has an eccenctric orbit as can be seen from the centers of the transits (0.0985 and 0.7561). Thus my assumption of a circular orbit does not hold. There might be a difference in apparent radii due to the orbit. A change from 0.95 to 0.77 is then needed, to explain the observations.
The difference in transit timings reveals at least a minimal eccentricity of 0.25, which corresponds to a relative distance variation between the two stars of 1.6. This might thus explain why my circular orbit does not work. So I need to refine my model to incorporate eccentricity. (Literature used Russell (1912) and Sterne (1939).
Tatooine star analysis
This a very interesting object: a double star with a planet circling around it. The excellent analysis of the previous posters seems to be the best solution. I wondered however if I would be able to expand on that by adding some numbers. Unfortunately most of the published formulae do not work here, as they all assume that the occulted star is stationary, which is certainly not the case here. So I had to invent some stuff to get to an extended explanation.

The first step involves the double star. As the transits have equal depth and are close to 50%, so both stars are assumed to be equal in size and the orbital plane (circular) has an inclination angle of 90 degrees. Thus we see the orbit edge on. The orbital period can be determined from two transits (i and i+1 - the two green transits) and is 2.976 days. Normally the width of a transitcan be used to calculate the half-major axis of the orbit. However formula 3 of Seager&Mallen;-Ornelas (2002) assumes however that the occulted star does not move, which it does in this case. Thus the observed width (0.13 days) must be doubled to get the correct one. From this the hal-major axis can be determined as 11.3 stellar radii.
To determine the movement of the planet, better timings of the transits are needed. In order to make the three extra transits more clear I subtracted the LC of the double star. This was done by shifting and overlaying an adjacent LC and then subtracting the two. The blue and green lines show where the transits were. The dots shows the results of the subtraction. And you as well that the subtraction did not succeed 100%.
Then these three transits were fitted to determine the transit times. The dermined values, such as the width (T) and impact parameter (b) have not much significance, as the formulae assume a static object. Using the start of the ingress of the first transit (day 55023.31) and the end of the egress of the third transit (day 55024.94), we can determined the speed of the planet. The model of the double star indicates where the stars are and by putting the planet next to the star, we set the position of the planet. I used the configuration indicated by @kianjin in his last animation as starting point.
This resulted in the following animation, which confirms @kianjin’s results. The first transit happens just as star 1 is turning prograde. The planet starts the transit and then star 1 speeds up and moves out under the planet. Transit 2 is when the planet passes in front of star 2. Star 2 is then retrograde, which results in a small transit width. Transit 3 happens when star 2 is retrograde.