I've been following this guide - http://wiki.openenergymonitor.org/index.php?title=Raspberry_Pi and http://openenergymonitor.org/emon/emoncms/installing-ubuntu-debian-pi - for installing emoncms on my RaspberryPi and all is going well except for the bit about SSH keys (http://openenergymonitor.org/emon/emoncms/installing-ubuntu-debian-pi section 6).
In the helpful tip:
Helpful tip: If doing this via SSH use $ cat /home/pi/.ssh/id_rsa.pub to display the SSH key in the terminal window. then select and [Ctrl + Shift + C] to copy to clipboard ready to paste into Github setting page.
Can anyone explain more about this - is it on the Raspberry, or PC? I've tried typing that into the Raspberry and also following this guide https://help.github.com/articles/generating-ssh-keys but I can't figure what to do.
Incase it matters, I am controlling the Raspberry from my laptop using Putty
I have tried going further without this SSH keys bit and everything appears to work, until i type my IP address into my browser - I get nothing. I guess this is related to the SSH keys?
I may just be getting a little out of my depth, but I have one of Martin Harizanov's RFM12B to raspberry boards which I hope to get all setup.
Thanks
Dennis
Re: emoncms onto RaspberryPI
I am thinking of creating a SD image with emoncms all set up, you will just have to plug in the RFM2Pi board. How does that sound?
I will be making step by step notes in the process and also make these available.
As per using git: you can also just download emoncms as a .zip and unzip it in /var/www
Also, note that latest emoncms (https://github.com/emoncms/emoncms) doeas have an add-on module for the rfm2pi board (https://github.com/emoncms/raspberrypi)
There is no documentation on how to install it yet, I am planning of creating such these days.
Re: emoncms onto RaspberryPI
That's very cool!
The only problem left is getting a Raspberry Pi :-). Waiting times are like 3 weeks (I live in the EU)...
Re: emoncms onto RaspberryPI
A ready loaded SD card sounds an excellent idea - I for one would certainly be interested.
As it is, I followed all the installation steps as per my initial post and all appeared to go well, except for the bit about SSH keys (it did say optional anyway so I initially carried on past it) and then at the bit where I type in my RaspberryPI IP address. Am I correct in that http://<IP_ADDRESS>/emoncms3 is what I type - <IP_ADDRESS> is definately the RaspberryIP LAN IP, although it does have a wifi adaptor but I tried it's IP address aswell with no luck (it appears intermittent whether it works or not when accessing with Putty).
Dennis
Re: emoncms onto RaspberryPI
I'm in!
Closer reading explains all - I was trying to change the settings for the non-modular version when I had installed the modular.
My IP address part was correct except the url ends in emoncms instead of emoncms3.
So I've logged into emoncms, ran minicom and I see serial data received so all looks good so far. I'll now wait patiently for the rest of the quide to complete.
Thanks
Re: emoncms onto RaspberryPI
Documentation for rm12pi is slowly taking shape: http://wiki.openenergymonitor.org/index.php?title=Raspberry_Pi, not quite complete yet. Trystran is working on making the modular emoncms easier to setup with auto module detection. Should be on github soon.
Yes, releasing a ready to go SD card image is on the plan.
Re: emoncms onto RaspberryPI
Hi,
thanks all, at same stage as Denis above,
I followed instructions and receiving fine (serial port RPi) from two nodes (emontx and emonglcd) see attached screen shots.
I also installed modular emoncms as described and can now register and login etc. ok
Looking forward to next instructions, in the mean time is there any point in trying to use script at
https://github.com/mharizanov/TinySensor/blob/42208d23cdc8d3308a844b8909... or other - more as a learning curve then to preempt proper solution.
Cheers
Peter
P.S. Anyone got description of serial input, with exception on first part on each line which is node ID it doesn't make much sense to me refer attached screenshots, tried changing temp and power to see which changed but not much clarity.
Re: emoncms onto RaspberryPI
I am correcting the link to the wiki in Glyn's post, it should be:
http://wiki.openenergymonitor.org/index.php?title=Raspberry_Pi
Great work there Glyn!
Just a comment on those that don't want to use or install git, you can use this alternative method to pull the latest emoncms and raspberrypi module:
cd /var/www/
sudo wget -O emoncms.tar.gz https://github.com/emoncms/emoncms/tarball/master
tar xvfz emoncms.tar.gz
sudo mv -i emoncms-emoncms-96885fe emoncms
cd /var/www/Modules/
sudo wget -O raspberrypi.tar.gz https://github.com/emoncms/raspberrypi/tarball/master
tar xvfz raspberrypi.tar.gz
sudo mv -i emoncms-raspberrypi-b9703b5 raspberrypi
NOTE that the bold part will change with every new version on github so you need to replace with the correct value
I added these ti the wiki
Also, you can create the tables required for the raspberrypi module by simply visiting the ADMIN tab, so that won't require any modification in index.php
I have the SD card image ready, but it is a 8GB one, this is the size of my SD card. I will see how large it is when zipped, and need to think of a way to share that over the interned without spending al my site allowed traffic ..
I will post details on my experience with setting the cron job for the raspberrypi module later today.
Re: emoncms onto RaspberryPI
Great thanks Martin.
I followed link above and it all seems to work fine, the serial port on Pi is reading from RFM12 you sent for both my emontx and emonglcd. The emoncms modular version is working on Raspberry Pi as per instructions above.
But what now? Where do I put API code for my emoncms and how do I use data received. Lots of questions if the answer is wait that's no problem but if you can advise I would like to try over weekend - great learning curve ( but don't want to waste your valuable time).
Cheer
Peter
Re: emoncms onto RaspberryPI
The rest is pretty easy, here is how I got it to work, maybe not the best way. No need to put the API anywhere, it already knows it as it is part of emoncms now.
Edit crontab this way:
and add this line to the end of it:
*/1 * * * * root cd /var/www/emoncms/Modules/raspberrypi && php raspberrypi_run.php
then reboot and you will start seeing data being fed in emoncms.
From there on it is the standard stuff, identify the inputs and log them to feeds.
Re: emoncms onto RaspberryPI
The original raspberrypi_run.php file runs too slow and omits transmissions. Here is my fix for those eager to test it out
Re: emoncms onto RaspberryPI
Thanks Martin. I'll add your non git based setup info to the wiki and get Trystan to take a look at the php script and your fix.
Re: emoncms onto RaspberryPI
If anyone notices any errors on the wiki. Feel free to edit. Your openenergymonitor.org login details should carry over. You might need to logout then log back in before loading the wiki for it to work.
Re: emoncms onto RaspberryPI
Hello again. Hope you can assist me a bit more please I'm a bit stuck.
Getting the following in emoncms "Message: The RFM12 to PI interface script is not running, you may need to configure cron"
Cron file below: I added job (php raspberrypi_run.php) correct I hope???? and reboot
# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
SHELL=/bin/sh
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# m h dom mon dow user command
17 * * * * root cd / && run-parts --report /etc/cron.hourly
25 6 * * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.daily )
47 6 * * 7 root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.weekly )
52 6 1 * * root test -x /usr/sbin/anacron || ( cd / && run-parts --report /etc/cron.monthly )
*/1 * * * * root cd /var/www/emoncms/Modules/raspberrypi && php raspberrypi_run.php
#
Also question about base id in emoncms - see screen shot. Is the id given to raspberry pi (RF12 module)
Cheers
Peter
Re: emoncms onto RaspberryPI
I get that from time to time, yet the INPUTS tab shows data is incomming. Do you have data beinf fed?
Re: emoncms onto RaspberryPI
Hi Martin,
I can use API help in emoncms using Set the input entry time manually: to send data ok see screen print attached.
As discusse I am receiving data on minicom ok for two nodes node =10 (emontx) and node =20 (emonglcd) both on group 210. A screen shot minicom is in my earlier post above.
Do I have to customize the file you provided above php raspberrypi_run.php ??? OR OTHER fILES
Cheers
Peter
Re: emoncms onto RaspberryPI
Yes please replace the raspberrypi_run.php with the content as shown above. The original file didn't work for me well as it was skipping most of the incoming messages. Simply copy/paste the content and save.
sudo nano /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php
Re: emoncms onto RaspberryPI
I already did this. My question is do I need to customize any part of the file for my nodes or my API key?
Thanks
Re: emoncms onto RaspberryPI
Great Martin, thanks for the speed improvements and working out the cron setup. I have updated your changes to the raspberrypi_run.php script to the repo. I've also updated the wiki documentation with the setup steps.
Re: emoncms onto RaspberryPI
Sorry Peter, I am reading between the lines :(
No, no need to set-up the API. The raspberrypi_run.php script pulls it out of the database. The script works by just capturing incoming packets from whatever node id. It expects that the node is sending payload of INT values only (no limit in the number of int values). Then it creates an input for that node in the form
node#_@ where # is the id of the remote node and @ is the payload int index. For emonTx we have a structure of this sort:
typedef struct { int power1, power2, power3, battery; } PayloadTX;
so you will receive something like this:
node10_1= power 1 reading
node10_2=power2 reading
node10_3=power3 reading
node10_4=battery
This is possible because all the values in the payload are ints. This is the part of the code that takes care of it:
$values = explode(' ',$data);
$msubs = "";
for($i=2; $i<(count($values)-1); $i+=2){
if ($i>2) $msubs .= ",";
$msubs .= $values[$i] + $values[$i+1]*256;
}
This approach utilizes the newly introduces CSV multinode concept, where you don't need to re-program the gateway (nanode or raspberry) with each additional node that you add to your system, as it automatically recognizes it and adds it to the list of inputs. quite neat, but at the cost of expecting only ints as payload. Not that this is a big problem, because lots of readings can be fit in an int. Temperatures multiplied by 100 also fit in int and then in emoncms you simply add a rule to multiply the incomng value by 0.01 to get the actual value.
If you still want to decode the incoming packets and make a good old json post, I have example of that in PHP here: https://github.com/mharizanov/TinySensor/blob/master/PHP_gateway/serial.php
it is pretty easy, and then you can have any type of packet, but will require script modification with the addition of each new node. Still I recommend to use the CSV approach.
Maybe in the future emoncms will support node configuration, where one of the settings will be a string to identify the incoming packet data structure types.
The ID of the RFM2Pi board should be some available number, 25 seems fine. It only matters, if you send packets. That's useful when you have the EMONGLCD for example, and need to send out the current time. I have example of this in my perl script, but I guess this is something yet to be added to the raspberrypi_run.php
I hope this helps
Re: emoncms onto RaspberryPI
Hi Martin/Trystan. Thanks a mil Martin for detailed explanation, helped a lot. I've reinstalled using latest files and followed new instructions published by Trystan.
Making progress, I can now see RFM12 to PI interface script is up and running in emoncms panel. I have verified again rf12 receiving ok
[RF12demo.Attiny84]
Available commands:
<nn> i - set node ID (standard node ids are 1..26)
(or enter an uppercase 'A'..'Z' to set id)
<n> b - set MHz band (4 = 433, 8 = 868, 9 = 915)
<nnn> g - set network group (RFM12 only allows 212, 0 = any)
<n> c - set collect mode (advanced, normally 0)
...,<nn> a - send data packet to node <nn>, with ack
...,<nn> s - send data packet to node <nn>, no ack
<n> l - turn activity LED on DIG8 on or off
<n> q - set quiet mode (1 = don't report bad packets)
Current configuration:
88 i24 g210 @ 868 MHz
10 60 0 62 0 14 0 231 101 26 5 60 0
10 61 0 63 0 11 0 228 101 26 5 60 0
10 61 0 62 0 17 0 172 101 26 5 61 0
No inputs yet for node10 - will keep you posted on progress, thanks again.
Cheers
Peter
P.S. From your post above "No, no need to set-up the API" can you please explain how script knows where to send inputs e.g. in the case were I have numerous registered users and API keys.
Re: emoncms onto RaspberryPI
Lets try couple things:
can you do the following from the console:
$ mysql -u root -p
it will ask for your password, enter the one you used when setting up emoncms.
Then change the database by typing:
mysql> use emoncms; <enter>
next, lets see what users you have in the system, we need the ID:
lets see what you have in the raspberrypi table:
mysql> select * from raspberrypi;
So for user ID (mharizanov) I do have all that is necessary - api key and settings.
can you repeat these steps and post the result? I suspect that if you have more than one user registered, it may be picking the wrong api key.
Re: emoncms onto RaspberryPI
4Here you go.
mysql> select id,username from users;
+----+----------+
| id | username |
+----+----------+
| 1 | root |
| 2 | peter |
+----+----------+
2 rows in set (0.00 sec)
mysql> select * from raspberrypi;
+--------+----------------------------------+--------+-----------+--------+----- -------+
| userid | apikey | sgroup | frequency | baseid | runn ing |
+--------+----------------------------------+--------+-----------+--------+----- -------+
| 1 | d92bd75a12b5bb2b567fd339320078d0 | 210 | 8 | 24 | 1351 360262 |
+--------+----------------------------------+--------+-----------+--------+-----
1 row in set (0.01 sec)
APIKEY above is same as root user in emoncms.
checked script was now updated version using sudo nano /var/www/emoncms/Modules/raspberrypi $ sudo nano raspberrypi_run.php - looks same.
I added second user peter to try something, I was not receiving input data before either.
Cheers
Peter
Re: emoncms onto RaspberryPI
ok from what you post, yser 'root' should be seeing inputs.
I am slowly running out of ideas what could be wrong, one more thing to try direct output from the rasperrypi_run.php:
can you please do the following:
cd /var/www/emoncms/Modules/raspberrypi/
php raspberrypi_run.php
let it run for a minute then copy/paste the output. You may get "already running", which will make the puzzle even more puzzling :)
I get this:
Re: emoncms onto RaspberryPI
Here you go
Thanks
Peter
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ php raspberrypi_run.php
PHP Warning: fopen(): Unable to find the wrapper "dio.serial" - did you forget to enable it when you configured PHP? in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 54
PHP Warning: fopen(dio.serial:///dev/ttyAMA0): failed to open stream: No such file or directory in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 54
PHP Warning: fclose() expects parameter 1 to be resource,
boolean given in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 105
Re: emoncms onto RaspberryPI
Hi Martin,
Thanks a mil, learned loads and its now working thanks to your great effort, much appreciated.
Here's the printouts you requested which pointed to mistake I made.
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ php raspberrypi_run.php
PHP Warning: fopen(): Unable to find the wrapper "dio.serial" - did you forget to enable it when you configured PHP? in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 54
PHP Warning: fopen(dio.serial:///dev/ttyAMA0): failed to open stream: No such file or directory in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 54
PHP Warning: fclose() expects parameter 1 to be resource,
boolean given in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 105
My mistake due to inexperience was in process: http://wiki.openenergymonitor.org/index.php?title=Raspberry_Pi
Step 3 $ sudo nano /etc/php5/cli/php.ini add extension=dio.so to file in the beginning of the ;Dynamic Extensions; section on line 843 [Ctrl+X] then [y] then [Enter] to save and exit
I placed code as described but never removed ";" obvious to a programmer but I thought about it and decided to leave ";" for some reason. ";" now removed and it's working now.
Peter
Re: emoncms onto RaspberryPI
gotcha :)
the PHP serial library isn't installed. Carefully follow this:
Re: emoncms onto RaspberryPI
I've been working through this again tonight and I cannot get the script to run - Message: The RFM12 to PI interface script is not running, you may need to configure cron
What I have done is reinstalled Modular emoncms & raspberrypi.
Added the line */1 * * * * root cd /var/www/emoncms/Modules/raspberrypi && php raspberrypi_run.php at the end of crontab
Minicom is showing nodes and data which looks ok.
I have set the RaspberryPI and emoncms to the same BaseID, frequency and group etc.
When I follow the above thread advice, when I get to the bit where I type mysql> select * from raspberrypi;, then the last box 'Running' displays NULL (everything else looks as it should).
Any idea's what I've missed/where I've gone worng?
Thanks
Dennis
Re: emoncms onto RaspberryPI
Hi Martin, Like I said in above post , when I removed the ; from start of code line 843 in php5/cli/php.ini, it started to work e.g. receiving input data from RF12 to emoncms.
Anyway I followed your instructions above and here is results.
See comments below:
Install serial PHP libraries
$ sudo apt-get install php-pear php5-dev
result
Reading package lists... Done
Building dependency tree
Reading state information... Done
php-pear is already the newest version.
php5-dev is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 55 not upgraded.
$ sudo pecl install channel://pecl.php.net/dio-0.0.6
result:
pecl/dio is already installed and is the same as the released version 0.0.6
install failed
Checkek below and already complete
$ sudo nano /etc/php5/cli/php.ini add extension=dio.so to file in the beginning of the ;Dynamic Extensions; section on line 843 [Ctrl+X] then [y] then [Enter] to save and exit
Restart apache $ sudo /etc/init.d/apache2 restart
result
[....] Restarting web server: apache2apache2: Could not reliably determine the server's fully qualified domain name, using <IP_ADDRESS> for ServerName
... waiting apache2: Could not reliably determine the server's fully qualified domain name, using <IP_ADDRESS> for ServerName
. ok
Then checked script:
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ php raspberrypi_run.php
Already running
Note that RF12 is still sending input data to emoncms.
Cheers
Peter
Re: emoncms onto RaspberryPI
Cheers
Peter
Re: emoncms onto RaspberryPI
Dennis, looks like the raspberrypi_run.php is not being run for some reason.
Lets try the same as we did for Peter: can you please do the following:
cd /var/www/emoncms/Modules/raspberrypi/
php raspberrypi_run.php
let it run for a minute then copy/paste the output.
Re: emoncms onto RaspberryPI
Thanks Martin
I ran the file and here is the result:
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ php raspberrypi_run.php
SERIAL RX: 10 38 1 78 0 0 0 62 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 74 0
294,78,0,24126,1037,1731,2818,3512,3587,2800,3462,2706,74
SERIAL RX:> 16i
SERIAL RX: 10 40 1 76 0 0 0 57 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 73 0
296,76,0,24121,1037,1731,2818,3512,3587,2800,3462,2706,73
SERIAL RX:> 4b
SERIAL RX: 10 30 1 76 0 0 0 57 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 72 0
286,76,0,24121,1037,1731,2818,3512,3587,2800,3462,2706,72
SERIAL RX: 20 152 6 9 0
1688,9
SERIAL RX:> 210g
SERIAL RX: 10 29 1 82 0 0 0 29 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 72 0
285,82,0,24093,1037,1731,2818,3512,3587,2800,3462,2706,72
SERIAL RX: 10 31 1 79 0 0 0 33 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 72 0
287,79,0,24097,1037,1731,2818,3512,3587,2800,3462,2706,72
SERIAL RX: 10 35 1 83 0 0 0 45 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 72 0
291,83,0,24109,1037,1731,2818,3512,3587,2800,3462,2706,72
SERIAL RX: 10 33 1 79 0 0 0 17 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 73 0
289,79,0,24081,1037,1731,2818,3512,3587,2800,3462,2706,73
SERIAL RX: 10 34 1 79 0 0 0 26 94 13 4 195 6 2 11 184 13 3 14 240 10 134 13 146 10 72 0
290,79,0,24090,1037,1731,2818,3512,3587,2800,3462,2706,72
Dennis
Re: emoncms onto RaspberryPI
hmm it looks exactly as it should.
Can you edit the raspberrypi_run.php to add the text in bold. That will print out the POST string and maybe it will ring a bell:
cd /var/www/emoncms/Modules/raspberrypi/
sudo nano raspberrypi_run.php
dnfthen scroll to find this function:Add the text in bold, underlined.
Then run the raspberrypi_run.php to see what it outputs. Try the address that it outputs in your laptop browser, just replace <IP_ADDRESS> with whatever IP address your PI has and report what happens
Re: emoncms onto RaspberryPI
I'm on my mobile just now so will have to try this a bit later, but to ensure I do it right can I as what you mean by 'dnf' then scroll to find this function:?
On raspberry boot up I have seen reference to <IP_ADDRESS>, but where exactly to I change this?
Sorry if this is simple questions but I've just recovered from hours of fixing my networking after setting up auto wlan login (not much fun!), so I just want to be sure....
thanks again
Dennis
Re: emoncms onto RaspberryPI
sorry the 'dnf' was unintentional, probably copy/paste thing, ignore it.
What I meant is that the raspberry will print out a message like this "<IP_ADDRESS>:80/emoncms/............" so in order to test that this works, you will have to replace the <IP_ADDRESS> with the IP of the Raspberry as <IP_ADDRESS> is a loopback IP address and you can't see that from another computer. The idea was to simulate a data post.
No problem just to let me know what the script outputs, we will try figure it out and you don't have tow worry about the <IP_ADDRESS>
I very much wanted to release my SD card image to make it easier for all, but I am having one heck of a time to save it, I get some weird errors
Re: emoncms onto RaspberryPI
I've added that line and below is what is on screen:
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ php raspberrypi_run.php
SERIAL RX:> 16i
SERIAL RX:> 4b
SERIAL RX:> 210g
SERIAL RX: 10 50 2 0 0 0 0 138 93 219 2 108 7 196 10 28 13 209 12 29 17 87 25 171 11 8 8 0
562,0,0,23946,731,1900,2756,3356,3281,4381,6487,2987,88
<IP_ADDRESS>:80/emoncms/input/post?apikey=6001ab5423cf985b5f1e3d151d904b08&node=10&csv=56 2,0,0,23946,731,1900,2756,3356,3281,4381,6487,2987,88
SERIAL RX: 10 71 11 0 0 0 0 182 92 219 2 108 7 196 10 28 13 209 12 29 17 87 25 171 11 93 0
2887,0,0,23734,731,1900,2756,3356,3281,4381,6487,2987,93
<IP_ADDRESS>:80/emoncms/input/post?apikey=6001ab5423cf985b5f1e3d151d904b08&node=10&csv=2887,0,0,23734,731,1900,2756,3356,3281,4381,6487,2987,93
SERIAL RX: 10 3 11 0 0 0 0 161 92 219 2 108 7 196 10 28 13 209 12 29 17 87 25 171 11 95 0
2819,0,0,23713,731,1900,2756,3356,3281,4381,6487,2987,95
<IP_ADDRESS>:80/emoncms/input/post?apikey=6001ab5423cf985b5f1e3d151d904b08&node=10&csv=2819,0,0,23713,731,1900,2756,3356,3281,4381,6487,2987,95
SERIAL RX: 10 189 10 0 0 0 0 7 93 219 2 114 7 196 10 28 13 203 12 60 17 131 25 184 11 94 0
2749,0,0,23815,731,1906,2756,3356,3275,4412,6531,3000,94
<IP_ADDRESS>:80/emoncms/input/post?apikey=6001ab5423cf985b5f1e3d151d904b08&node=10&csv=2749,0,0,23815,731,1906,2756,3356,3275,4412,6531,3000,94
Hopefully this will give some tell tale info?
Thanks
Dennis
Re: emoncms onto RaspberryPI
Everything now appears to be working, and the usual typo was to blame.
Up until a few minutes ago I was manually typing everything into the raspberrypi via Putty, but I've just figured how to copy/paste (simple, but true...).
I had missed several spaces in the line - */1 * * * * root cd /var/www/emoncms/Modules/raspberrypi && php raspberrypi_run.php
Once this was corrected, all is now working correctly.
I'm sorry for your troubles, and thank you very much once again for helping me.
Dennis
Re: emoncms onto RaspberryPI
Now when I'm trying to setup feeds from the inputs I only have an option to select the process, and I have no options for the argument or actions. The attached screenshot should explain.
I'm sure it'll probably be something simple, but I really cannot figure it. Any idea's.
EDIT: Figured it out - it's different from the online emoncms as you need to setup inputs with http://IPADDRESS/emoncms/input/process/add?inputid=1&type=1&arg=-1&arg2=power.
Thanks
Re: emoncms onto RaspberryPI
Hi, Dispite getting RPi working above with the help of Martin, I decided to begin fresh install equipped with my new gained knowledge. Followed Documentation for rm12pi http://wiki.openenergymonitor.org/index.php?title=Raspberry_Pi and using Martin Harizanov's RFM12B module I got my Raspberry pi working with two modules (emontx and emonglcd).
Great work guys.
Cheers
Peter
Re: emoncms onto RaspberryPI
Hi, Getting some very unusual behavior on inputs. I've started getting input data for many different nodes with node1_x, nodes2_x and CSV. I have attached PDF. minicom -b 9600 -o -D /dev/ttyAMA0 seems very slow and doesn't reflect inputs received as attached.
Cheers
Peter
Re: emoncms onto RaspberryPI
Yes, I noticed that myself. It happens when the PHP tryis to interpret the help messages that are shown then the RFM2Pi board starts up.
Here is a fix, just look up that section in the code in raspberrypi_run.php and replace:
if ($data[0]!=">")
{
$values = explode(' ',$data);
if ($values && is_numeric($values[1]))
{
$msubs = "";
for($i=2; $i<(count($values)-1); $i+=2){
if ($i>2) $msubs .= ",";
$msubs .= $values[$i] + $values[$i+1]*256;
}
echo $msubs."\n";
$url = "/emoncms/input/post?apikey=".$apikey."&node=".$values[1]."&csv=".$msubs;
getcontent("localhost",80,$url);
}
}
Then remove the 'dirty' inputs by deleting them in the INPUTS tab.
Glyn, Trystan: can you also fix this on Github?
Re: emoncms onto RaspberryPI
Ok, I've broke it!
As I was having similar problems to above then I updated the raspberrypi_run.php but now nothing works again. I've tried working through the checks as above and it will not run php raspberrypi_run.php. It displays:
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ php raspberrypi_run.php
PHP Parse error: syntax error, unexpected end of file in /var/www/emoncms/Modules/raspberrypi/raspberrypi_run.php on line 133
Below is a copy/paste of the section in raspberrypi_run.php, incase I have done something silly:
{
echo "SERIAL RX:".$data;
if ($data[0]!=">")
{
$values = explode(' ',$data);
if ($values && is_numeric($values[1]))
{
$msubs = "";
for($i=2; $i<(count($values)-1); $i+=2){
if ($i>2) $msubs .= ",";
$msubs .= $values[$i] + $values[$i+1]*256;
}
echo $msubs."\n";
$url = "/emoncms/input/post?apikey=".$apikey."&node=".$values[1]."&csv=".$msubs;
getcontent("localhost",80,$url);
}
}
}
}
fclose($f);
Any idea's?
Also when something is updated in github/emoncms, how do we do an update on the RaspberryPI?
Dennis
Re: emoncms onto RaspberryPI
Unbalanced parentheses! Either one too many closing, or a missing opening, but I don't know which or where.
Re: emoncms onto RaspberryPI
Hello all, thanks Martin, just uploaded your fix.
Dennis I think you might one additional } before fclose($f).
PS: wrote a bit of info on the new modular emoncms version in the blog today which hopefully gives a bit more context and detail on the changes.
Re: emoncms onto RaspberryPI
Thanks for that
I manually copy/pasted the updated git changes and it now works again. When I figures how to 'git pull' I got the below:
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $ git pull
Updating 28dcdc3..2937e12
error: Your local changes to the following files would be overwritten by merge:
raspberrypi_run.php
Please, commit your changes or stash them before you can merge.
Aborting
pi@raspberrypi /var/www/emoncms/Modules/raspberrypi $
I assume this was because I had done a manual update, but is there an easy way to get it back able to update via git pull?
Many thanks again to all who have helped me.
Dennis


Tutorials¶
Tomographic reconstructions¶
Reconstruction with a CNN¶
In this tutorial we will reconstruct an image from a sinogram using a convolutional neural network. We have a network architecture for this task: models.cnn_reconstruct.models.reconstruct_cnn
Step 0¶
Generate the data. We have some scripts to generate sample data for this task. LibShapes.py Alternatively download sample data from here: http://tiny.cc/vdl9rz
Step 1¶
When the data is generated we now load it up. Use the utils.tools.read_reconstruct_library helper function to make this easier. We then shuffle around the image/sinogram pairs to make sure that we don’t have any false ordering. We alsoe need to make sure that superres-ml is on our pythonpath. Split the data into training and test data.
from utils.tools import read_reconstruct_library
import sys
sys.path.append('/path/to/super-resolution-ml/')
images, sinos, nim = read_reconstruct_library('data/reconstruction/shapes_random_noise_64px_norm.h5')
index = np.arange(nim)
np.random.shuffle(index)
images = images[index,:,:,:]
sinograms = sinos[index,:,:,:]
sinograms_test = sinograms[9000:]
images_test = images[9000:]
sinograms = sinograms[:9000]
images = images[:9000]
Step 2¶
Set up the network. We import the reconstruct_cnn netowrk from out superres-ml model library. We then compile the network to use the Adam optimiser and to monitor the mae and mse during training. We add a callback, which makes the training stop if the metrics have not improved for three steps.
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import EarlyStopping
from models.cnn_reconstruct.models import reconstruct_cnn
model_rec = reconstruct_cnn(sinos.shape[1], sinos.shape[2])
model_rec.compile(optimizer = Adam(lr = 0.000025), loss = 'mean_squared_error', metrics = ['mae', 'mse'])
my_callbacks = [EarlyStopping(patience=3)]
Step 3¶
Train the model!
training = model_rec.fit(sinograms, images,
validation_split = 0.1,
batch_size=32,
epochs = 100,
verbose = True,
callbacks=my_callbacks)
history = model_rec.history
Reconstruction with a Dense Network¶
This tutorial is just like the one above, but we use a dense network at the start before convolutions. This kind of network gives very good results but requires huge memory for any larger images. See the architecture below.
Steps 0, 1 and 3 are the exact same as for the CNN.
Step 0¶
Generate the data. We have some scripts to generate sample data for this task. LibShapes.py Alternatively download sample data from here: http://tiny.cc/vdl9rz
Step 1¶
When the data is generated we now load it up. Use the utils.tools.read_reconstruct_library helper function to make this easier. We then shuffle around the image/sinogram pairs to make sure that we don’t have any false ordering. We alsoe need to make sure that superres-ml is on our pythonpath. Split the data into training and test data.
from utils.tools import read_reconstruct_library
import sys
sys.path.append('/path/to/super-resolution-ml/')
images, sinos, nim = read_reconstruct_library('data/reconstruction/shapes_random_noise_64px_norm.h5')
index = np.arange(nim)
np.random.shuffle(index)
images = images[index,:,:,:]
sinograms = sinos[index,:,:,:]
sinograms_test = sinograms[9000:]
images_test = images[9000:]
sinograms = sinograms[:9000]
images = images[:9000]
Step 2¶
Set up the network. We import the reconstruct_cnn netowrk from out superres-ml model library. We then compile the network to use the Adam optimiser and to monitor the mae and mse during training. We add a callback, which makes the training stop if the metrics have not improved for three steps.
from tensorflow.keras.optimizers import Adam
from tensorflow.keras.callbacks import EarlyStopping
from models.dense_reconstruct.models import dense_reconstruct
model_rec = dense_reconstruct(sinos.shape[1], sinos.shape[2])
model_rec.compile(optimizer = Adam(lr = 0.000025), loss = 'mean_squared_error', metrics = ['mae', 'mse'])
my_callbacks = [EarlyStopping(patience=3)]
Step 3¶
Train the model!
training = model_rec.fit(sinograms, images,
validation_split = 0.1,
batch_size=32,
epochs = 100,
verbose = True,
callbacks=my_callbacks)
history = model_rec.history
Segmentation of X-ray images¶
Binary segmentation¶
This tutorial looks at segmentation of sections of an image, for example collected from X-ray imaging. We have a set of images where we have already labelled what the different parts of the image are, now we want to train and apply a model to another set, labelling new X-ray images.
To do this we will use a U-net architecture. There is one big challenge in using most U-net architectures that you will find on the web.
The image sizes are very large. This means that the image and the model cannot fit together in the memory.
To overcome the problem we will use a routine in superres-tomo to create patches from the image and learn sequentially from each patch. To do do this we have implemented the data_handeling.generators.mask_patch_from_file function which acts as a generator to feed the network for training.
Step 0¶
Generate the data. There is a helper script in the directory data/segmentation run this to generate the data for this tutorial. Run this script to generate the data for this tutorial.
Also make sure the superres-ml package is in your pythonpath
import sys
sys.path.append('/path/to/super-resolution-ml/')
Step 1¶
Once the data is in place we are ready to start setting up the U-net. Tell the code where to find the images and masks, the types of file to expect.
datapath= 'data/segmentation/train/' #<the root directory of images and masks for training>
valpath= 'data/segmentation/val/' #<the root directory of images and masks for validation>
img_dir= 'noiseless/' # <the subdirectory where images are>
mask_dir= 'label/' #<the subdirectory where masks are>
ftypes= ['./tiff'] # (<filetypes to look for>) # e.g. ('.tif')
Step 2¶
Set up the information about the size of the original image and the size of the patches to take from the image. Also here you can define a list of which patches to use. This last feature is useful when the interesting features are only in a section of the image. You can specify the particular patches to consider for the training. The numbering of patches starts from zero and proceeds left to right top to bottom. If the patch list is left empty the generator uses all patches.
image_shape = (1280, 1280)
patch_shape = (64, 64)
patch_range = []
Step 3¶
Set up the generator. This is the function that will flow the patches from the images to the netowrk for training.
from data_handeling.generators import mask_patch_from_file
myGene = mask_patch_from_file(datapath,
img_dir, mask_dir,
patch_shape, image_shape,
types = ftypes, patch_range=patch_range,
debug=False,
batch_size = 1,
normalise_images=False)
valGene = mask_patch_from_file(valpath,
img_dir, mask_dir,
patch_shape, image_shape,
types = ftypes, patch_range=patch_range,
debug=False,
batch_size = 1,
normalise_images=False)
Step 4¶
Define the netowrk architecture, the hyperparameters and the training time. Here the input size is the dimension of the patches, also we have just 1 channel as the image is greyscale. We use a standard Adam optimiser. We use binary_crossentropy as the loss function and also monitor the accuracy during training.
from models.u_net.models import unet_3layer
import models.losses.custom_loss_functions as losses
from tensorflow.keras.optimizers import Adam
model = unet_3layer(input_size = (patch_shape[0], patch_shape[1], 1))
opt = Adam()
model.compile(loss=losses.weighted_cross_entropy(2), optimizer=opt,
metrics=["accuracy"])
Step 5¶
Train and save!
epochs = 6
steps_per_epoch = 2000
model.fit(myGene, steps_per_epoch=steps_per_epoch,
epochs=epochs, validation_data=valGene, validation_steps=100)
model.save_weights('saved_weights.hdf5')
Step 6¶
Run the model for inference. Having trained the model on some images you can now try to deploy on
new examples. We have the utils.tools.inference_binary_segmentation()
helper
function to do this. First we load up the saved model and weights.
from utils.tools import inference_binary_segmentation
datapath = 'data/segmentation/test/noiseless/'
patch_shape = (64, 64)
image_shape = (1280, 1280)
savepath = './inferred_masks/'
inference_binary_segmentation(datapath, patch_shape, image_shape, model,
file_prefix='binary_mask', savepath=savepath, fig_size=(8, 8),
normim=False)
In the inferred_masks directory there should now be a masking file something like:
Denoising of X-ray images¶
Variational Autoencoder¶
Often images that are reconstructed contain low signal to noise ratios, if the dose was low or the collection time short. In these cases it would often be desireable to remove the noise and accentuate the signal in an image. We can do this using a Variational Autoencoder (VAE)
Step 0¶
Set up the data. You can use the data/denoising/generatedata.py script to generate some example data. Then use the helper functions build_list_images and build_autoencoder_data to build the data set ready to train the VAE.
We need to specify the data shape with the input_data keyword and then specify directories to find the training and validation inputs and labels.
import sys
sys.path.append('/path/to/super-resolution-ml/')
from data_handeling.tools import build_list_images
from models.autoencoder.tools import build_autoencoder_data
input_data = (64, 64, 1)
datapath = '../data/denoising/train/noisy/'
Xfiles = build_list_images(datapath, types = ['.tiff'])
datapath = '../data/denoising/train/noiseless/'
yfiles = build_list_images(datapath, types = ['.tiff'])
X, labels = build_autoencoder_data(Xfiles, yfiles=yfiles, input_data=input_data)
datapath = '../data/denoising/test/noisy/'
Xfiles = build_list_images(datapath, types = ['.tiff'])
datapath = '../data/denoising/test/noiseless/'
yfiles = build_list_images(datapath, types = ['.tiff'])
xtest, ltest = build_autoencoder_data(Xfiles, yfiles, input_data=input_data)
Step 1¶
Set up the VAE. Here we import the model as well as functions to train and run the model and an optimiser. We need to set the number of units to use in the bottle-neck (latent) space.
from models.autoencoder.models import CVAE
from models.autoencoder.tools import vae_train, vae_inference
from tensorflow.keras.optimizers import Adam
latent_dim = 16
optimizer = Adam(lr=0.0001)
epochs = 500
model = CVAE(latent_dim, input_data)
Step 2¶
Train the model. Using the vae_train function set the model to train.
vae_train(model, X, labels, xtest, ltest, epochs, optimizer, sigmoid=False)
Step 3¶
Try the trained model out on some of the test data.
out = vae_inference(model, np.expand_dims(X[9], axis=0), sigmoid=True)


GeoMesa Development¶
This chapter describes how to build GeoMesa from source and provides an overview of the process of developing GeoMesa.
Using Maven¶
The GeoMesa project uses Apache Maven as a build tool. The Maven project’s
Maven in 5 Minutes provides a
quick introduction to getting started with its mvn
executable.
Building from Source¶
These development tools are required:
- Java JDK 8
- Apache Maven 3.2.2 or later
- A
git
client
The GeoMesa source distribution may be cloned from GitHub:
$ git clone https://github.com/locationtech/geomesa.git
$ cd geomesa
This downloads the latest development version. To check out the code for the latest stable release
($VERSION
= 2.0.0-m.1):
$ git checkout tags/geomesa-$VERSION -b geomesa-$VERSION
Building and dependency management for GeoMesa is handled by Maven.
The Maven pom.xml
file in the root directory of the source distribution contains a
list of dependent libraries that will be bundled together for each module of the program. Build using the
mvn
executable:
$ mvn clean install
The skipTests property may be used to reduce build time, as it omits the test phase of the build process:
$ mvn clean install -DskipTests
To compile for Google Bigtable, use the bigtable
profile:
$ mvn clean install -Pbigtable
The build/mvn
script is a wrapper around Maven that builds the project using the
Zinc incremental compiler:
$ build/mvn clean install -DskipTests
Scala¶
For the most part, GeoMesa is written in Scala, and is compiled with Scala 2.11.7.
Using the Scala Console¶
To test and interact with core functionality, the Scala console can be invoked in a couple of ways. For example, by running this command in the root source directory:
$ mvn scala:console -pl geomesa-accumulo/geomesa-accumulo-datastore
The Scala console will start, and all of the project packages in geomesa-accumulo-datastore
will be loaded along
with JavaConversions
and JavaConverters
.
GeoMesa Project Structure¶
- geomesa-accumulo:
DataStore
implementation for Apache Accumulo - geomesa-archetypes: Template modules for Maven builds
- geomesa-arrow: Apache Arrow integration and
DataStore
implementation - geomesa-bigtable:
DataStore
implementation for Google Bigtable - geomesa-blobstore: Accumulo-backed store designed for large files which have associated spatio-temporal data
- geomesa-cassandra:
DataStore
implementation for Apache Cassandra - geomesa-convert: Configurable and extensible library for converting arbitrary data into
SimpleFeature
s - geomesa-features: Custom implementations and serialization of
SimpleFeature
s - geomesa-filter: Library for manipulating and working with GeoTools
Filter
s - geomesa-fs:
DataStore
implementation for flat files - geomesa-geojson: API and REST-ful web service for working directly with GeoJSON
- geomesa-hbase:
DataStore
implementation for Apache HBase - geomesa-index-api: Core indexing and
DataStore
code - geomesa-jobs: Map/reduce integration
- geomesa-jupyter: Jupyter notebook integration
- geomesa-kafka:
DataStore
implementation for Apache Kafka, for near-real-time streaming data - geomesa-lambda:
DataStore
implementation that seamlessly uses Kafka for frequent updates and Accumulo for long-term persistence - geomesa-memory: In-memory indexing code
- geomesa-metrics: Extensions and configuration for DropWizard metrics integration
- geomesa-native-api: Non-GeoTools API for persisting and querying data in Accumulo
- geomesa-process: Analytic processes optimized for GeoMesa stores
- geomesa-security: API for managing security and authorization levels in GeoMesa
- geomesa-spark: Apache Spark integration
- geomesa-stream:
DataStore
implementation that reads features from arbitrary URLs - geomesa-test: Integration testing scripts
- geomesa-tools: Command-line tools for ingesting, querying and managing data in GeoMesa
- geomesa-utils: Common utility code
- geomesa-web: REST-ful web services for integrating with GeoMesa
- geomesa-z3: Z3 space-filling-curve implementation
- geomesa-zk-utils: Zookeeper utility code


Source code for amaascore.assets.bond_future
from __future__ import absolute_import, division, print_function, unicode_literals
from datetime import date
from decimal import Decimal
from amaascore.assets.future import Future
[docs]class BondFuture(Future):
def __init__(self, asset_manager_id, asset_id, expiry_date, underlying_bond_tenor, underlying_bond_coupon,
cheapest_to_deliver_id=None, asset_issuer_id=None, asset_status='Active', issue_date=date.min,
description='', country_id=None, venue_id=None, links={}, references={}, *args, **kwargs):
"""
:param asset_manager_id: The asset manager who owns the data for this BondFuture
:param asset_id: The owning asset manager's unique identifier for this BondFuture
:param expiry_date: The date on which this BondFuture will expire
:param underlying_bond_tenor: The tenor of the bond on which this is a future
:param cheapest_to_deliver_id: Populated from the server, cannot be calculated in the SDK.
:param asset_issuer_id: The owning asset manager's identifier for the issuer of this future
:param asset_status: The status of this BondFuture
:param issue_date: The date on which this BondFuture was created
:param description: A human-readable description of this BondFuture
:param country_id: The ISO 3166-1 alpha-3 code for the country that this BondFutureOption was issued in
:param venue_id: The ISO-10383 identifier for the venue on which this BondFutureOption trades
:param references: A dictionary of additional References for this BondFutureOption
:param args:
:param kwargs:
"""
self.cheapest_to_deliver_id = cheapest_to_deliver_id
self.expiry_date = expiry_date
self.underlying_bond_tenor = underlying_bond_tenor
self.underlying_bond_coupon = underlying_bond_coupon
super(BondFuture, self).__init__(asset_manager_id=asset_manager_id, asset_id=asset_id,
asset_issuer_id=asset_issuer_id, asset_status=asset_status,
description=description, country_id=country_id, venue_id=venue_id,
links=links, references=references, issue_date=issue_date,
*args, **kwargs)
@property
def underlying_bond_coupon(self):
if hasattr(self, '_underlying_bond_coupon'):
return self._underlying_bond_coupon
@underlying_bond_coupon.setter
def underlying_bond_coupon(self, underlying_bond_coupon):
"""
The coupon paid out by the underlying bond. Represented as a fraction of 1 (e.g. 0.05 is 5%).
:param underlying_bond_coupon:
:return:
"""
if underlying_bond_coupon is not None:
self._underlying_bond_coupon = Decimal(underlying_bond_coupon)


Benjamin's Website
Home
About
Project Ideas
Bucket List
Game?
Questions
Is my full name Benjamin James Clark?
Do I have more than 5 siblings?
Do I live with parents?
Have I ever had a parachute malfunction while jumping from a plane?
Will you be my neighbor?


public interface ProcessInstanceHistoryLog
| Modifier and Type | Method and Description |
|---|---|
String |
getBusinessKey()
The user provided unique reference to this process instance.
|
String |
getDeleteReason()
Obtains the reason for the process instance's deletion.
|
Long |
getDurationInMillis()
The difference between
getEndTime() and getStartTime() . |
Date |
getEndTime()
The time the process was ended.
|
List<HistoricData> |
getHistoricData()
The trail of data, ordered by date (ascending).
|
String |
getId()
The process instance id (== as the id for the runtime
process instance ). |
String |
getProcessDefinitionId()
The process definition reference.
|
String |
getStartActivityId()
The start activity.
|
Date |
getStartTime()
The time the process was started.
|
String |
getStartUserId()
The authenticated user that started this process instance.
|
String |
getSuperProcessInstanceId()
The process instance id of a potential super process instance or null if no super process instance exists
|
String |
getTenantId()
The tenant identifier for the process instance.
|
String getId()
process instance
).String getBusinessKey()
String getProcessDefinitionId()
Date getStartTime()
Date getEndTime()
Long getDurationInMillis()
getEndTime()
and getStartTime()
.String getStartUserId()
String getStartActivityId()
String getDeleteReason()
String getSuperProcessInstanceId()
String getTenantId()
List<HistoricData> getHistoricData()
Copyright © 2017 Flowable. All rights reserved.


A realtime components library for building reactive UIs.
Components for everything.
Build data driven lists, dropdowns, sliders, buttons, searchboxes, calendars, feeds and maps.
Chain components reactively.
A declarative syntax for reactively chaining components. Optionally, subscribe to data updates in realtime.
Works with your CSS tooling.
Introduces minimum styling, each component adheres to a simple and consistent CSS API. Comes with light and dark themes.
A display of meetup RSVPs filtered by city and topics. Show RSVP data in a popover when clicked on a marker.
It uses SingleList, MultiList and ReactiveMap components.
Demo CodeA display of historical earthquake data across the globe filtered by places, magnitude and year.
It uses MultiList, RangeSlider and ReactiveMap components.
Demo CodeWeather data is fetched from openweathermap.org and stored in an appbase.io app. In this example, we run a GeoBoundingBox query using the boundary of the maps to fetch all such locations indexed in the app.
It uses the ReactiveMap component.
Demo CodeA display of Foursquare checkins filtered by city and categories. The example uses dynamic markers depending on the type of category. It also displays the checkin info on click in a popover.
It uses SingleList, MultiList and ReactiveMap components.
Demo CodeA direction navigation example between two places A and B. Places are searchable via a full-text search box.
It uses two PlacesSearch and oneReactiveMap components.
Demo CodeA heatmap view based on a simulation of frequent events, e.g. calculating the surge price in a neighborhood or city for an on-demand delivery service. It divides the area into a grid and creates a realtime GeoBoundingBox query for each cell, the frequency then visualized with a shade of color added to the cell area.
It uses the ReactiveMap component and applies a customQuery and renders a polygon layer on the onData event.
Demo Code


If the button has a:
White strip: release when the countdown timer has a 1 in any position.
Blue strip: release when the countdown timer has a 4 in any position.
Yellow strip: release when the countdown timer has a 5 in any position.
Other colored strip: release when the countdown timer has a 1 in any position.
Instructions
- ""
- - bottom left
- Blank
- - center right
- C
- - top right
- Cee
- - bottom right
- Display
- - bottom right
- First
- - top right
- Hold On
- - bottom right
- LED
- - center left
- Lead
- - bottom right
- Leed
- - bottom left
- No
- - bottom right
- Nothing
- - center left
- Okay
- - top right
- Read
- - center right
- Red
- - center right
- Reed
- - bottom left
- Says
- - bottom right
- See
- - bottom right
- Their
- - middle right
- There
- - bottom right
- They Are
- - center left
- They're
- - bottom left
- UR
- - top left
- Yes
- - center left
- You
- - center right
- Your
- - center right
- You're
- - center right
- You Are
- - bottom right
Is the wire blue?
Is the wire red?
Is the star present?
Is the LED on?
Answer:
Enter all the letters for a column in lowercase with no spaces
Possible words:
Select the color and letter of the wire, then hit submit
Wire:
1
Answer:
Select the four symbols shown on the bomb, then have the defuser click the symbols from top to bottom


See Part 1 first
For the past several days I’ve had the app on my phone and used it to enter in wines to see how the UI was working. Yesterday, I integrated Core Data (Apple’s Object/Relational Mapper (ORM), for lack of a better description) so that I could actually save some data. I discovered some nuances to using Core Data, as well as a refinement in the UI.
UI
Last night, I had both my girlfriend Amy and my good friend Clay (who is also reasonably into wine) play around with the “new wine” screen. Neither have an iPhone, and there were a few obvious problems:
- They were very unaccustomed to the “Done” button being in the upper-right corner, as well as the “slot-machine” control
- Both had trouble with the “Wine Name” concept
- Both had trouble dismissing the keyboard
- Clay thought he was entering search terms and not a new Wine
Later that evening, I had a glass of wine at a bar and entered it into my app. Up until this point, I was just typing in wines I knew about, so this was the first “real use” of the app in the field. I quickly realized that the “Wine Name” concept, while important, was too vague and confusing to be the first field you enter. Most wines are known by the vineyard and some don’t even have proper names or appellations. So, I swapped the fields and added some examples in the placeholder text:
I also added a title to indicate that this screen is for adding a new wine. Finally, I used the background button trick along with some events on the rating and type controls to dismiss the keyboard if you tap anywhere outside of a text field.
This feels much cleaner and flows a bit better. While varietal is probably the third most important thing (at least for New World wines), the slot-machine control would be awkwardly placed right below the vineyard/vintage text fields, so I left it where it was.
As to Clay and Amy’s confusion over some idiomatic iPhone design choices, I’m not worrying about them a whole lot; a typical iPhone user will understand what’s going on (I hope :).
Core Data
Backing all this is Apple’s Core Data, which grew out of the Enterprise Objects Framework (and was, incidentally, my first exposure to an ORM way back in 1998), is the simplest and most idiomatic way to store and manage data on the iPhone. As with Interface Builder, you create the model visually, using a simplistic data modelling tool. I set up the bare bones of my data model and generated the classes.
The first problem I ran into was in changing the model after the database had been created on the device. Core Data doesn’t migrate your model for you by default. I ended up starting over with a “versioned” model and implementing their default migration. This will probably work for simple changes, but for more complex changes, it looks like it’s somewhat difficult to migrate the model. An unfortunate reason to do some Big Design Up Front.
My next problem was initializing reference data. In my case, I wanted the list of varietals as well as the list of wine types (e.g. “red”, “white”) to be in the database and managed by Core Data. I ended up creating an array of the values inside the app and then checking the database for their existence, adding them if they were missing. It’s a bit cheesy, but I can extract the lists to plist files later. It did give me a chance to play with Objective-C’s blocks feature. I needed to map my list of Varietal
objects to a list of strings, so I could compare that list against my default list. While NSArray
doesn’t provide a map function, it does provide the equivalent of Ruby’s each
or Scala’s foreach
. In true Apple/Objective-C style, it’s called enumerateObjectsUsingBlock
:)
NSMutableArray *strings = [NSMutableArray arrayWithCapacity:[array count]];
[array enumerateObjectsUsingBlock:^(id obj, NSUInteger i, BOOL *stop) {
[strings addObject:[obj valueForKey:@"name"]];
}];
The stop
pointer is an out-only variable that you set to YES to allow for an early exit from the loop. I’m glad they’ve adopted this functional style; I forsee explicit loops becoming just as quaint as GOTOs in the near future.
One thing bugged me about this process, however. I had these generated classes and it wasn’t clear how to add my own methods to them without losing the code every time I re-generated my model. Enter mogenerator. This provides a more sophisticated bit of code generation, givng you two classes for each model: one for machines (i.e. for Core Data to manage) and a subclass for people (to which I can add custom methods). Perfect! I wasn’t able to incorporate it into XCode, but I’m happy running in on the command line as needed for now.
Random Bits
I spent more time than I would’ve liked tracking down a nasty bug where every attempt to convert a string to a number (for the wine vintage year) resulted in a nil
number. It turns out I was confused about when some object lifecycle methods were being called and my pointer to an NSNumberFormatter
was, in fact, pointing to nil
. Unlike Java, where you’d get a NullPointerException
, or C, where you’d get a core dump, it seems Objective-C just returns nil
and doesn’t even issue a warning. Very strange. Once I realized that, the solution was obvious.
I’m still not 100% sure I’m structuring my code properly, but Stack Overflow’s stalwart iPhone SDK answerers have been incredibly helpful in pointing me in the right direction.
Next Steps
Now that I’ve got the ability to save and retrieve data, the next step is to start looking to browsing, viewing, and editing the database. I think the domain is restricted enough that I can use the iPhone’s idiomatic drill-down table navigation to filter the database.


| 3807 - Marble Game World Finals - Tokyo - 2006/2007 | |||||
| Submit | Ranking |
A Marble Game is played with M
A game board may contain walls. Each wall is one unit long and stands between two adjacent unit squares. Two squares are considered adjacent if and only if they share a side.
At the beginning of the game, all marbles are placed on the board, each in a different square. A ``move" consists of slightly lifting a side of the game board. Then all marbles on the board roll downward toward the opposite side, each one rolling until it meets a wall or drops into an empty hole, or until the next square is already occupied by another marble. Marbles roll subject to the following restrictions:
The game is over when each marble has dropped into a hole with the corresponding number.
The figure below illustrates a solution for a game played on a
4×4
Your program should determine the fewest number of moves to drop all the marbles into the correct holes -- if such a move sequence is possible.
The input file contains several test cases. The first line of each test case contains three numbers: the size N
The input file ends with a line containing three zeroes.
For each test case, print the case number (beginning with 1) and the minimal number of moves to win the game. If the game cannot be won, print the word ``impossible". Put a blank line after each test case. Use the format of the sample output below.
Tests-Setter: Derek Kisman
Input
Output
Sample Input
4 3 1
0 1
1 0
1 2
2 3
2 1
3 2
1 1 1 2
3 2 2
0 0
0 1
0 2
2 0
2 0 1 0
2 0 2 1
0 0 0
Sample Output
Case 1: 5 moves
Case 2: impossible
Tokyo 2006-2007


InitNetwork()
语法
Result = InitNetwork()
This function must be called before any other function from the Network library.
参数
无.
返回值
Returns nonzero if the network was initialized correctly or zero if not.
已支持操作系统
所有


CSPICE_GFSNTC determines time intervals for which a coordinate of
an surface intercept position vector satisfies a numerical constraint.
Given:
Parameters-
All parameters described here are declared in the header file
SpiceGF.h. See that file for parameter values.
SPICE_GF_CNVTOL
is the convergence tolerance used for finding endpoints of
the intervals comprising the result window.
SPICE_GF_CNVTOL is used to determine when binary searches
for roots should terminate: when a root is bracketed
within an interval of length SPICE_GF_CNVTOL, the root is
considered to have been found.
The accuracy, as opposed to precision, of roots found
by this routine depends on the accuracy of the input
data. In most cases, the accuracy of solutions will be
inferior to their precision.
Arguments-
target the name of the target body. Optionally,
you may supply the integer ID code for the object as an
integer string. For example both 'MOON' and '301'
are legitimate strings that indicate the moon is the
target body.
[1,c1] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
On calling cspice_gfsntc, the kernel pool must contain the
radii data corresponding to 'target'.
fixref the name of the body-fixed, body-centered reference frame
associated with the target body 'target'.
[1,c2] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
The SPICE frame subsystem must recognize the 'fixref' name.
method the name of the method to use for the surface intercept
calculation.
[1,c3] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
The accepted values for method:
'Ellipsoid' The intercept computation uses
a triaxial ellipsoid to model
the surface of the target body.
The ellipsoid's radii must be
available in the kernel pool.
The 'method' string lacks sensitivity to case, and to leading
and trailing blanks.
abcorr describes the aberration corrections to apply to the state
evaluations to account for one-way light time and stellar
aberration.
[1,c4] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
This routine accepts the same aberration corrections as does
the routine spkezr_c. See the header of spkezr_c for a
detailed description of the aberration correction options.
For convenience, the options are listed below:
'NONE' Apply no correction.
'LT' "Reception" case: correct for
one-way light time using a Newtonian
formulation.
'LT+S' "Reception" case: correct for
one-way light time and stellar
aberration using a Newtonian
formulation.
'CN' "Reception" case: converged
Newtonian light time correction.
'CN+S' "Reception" case: converged
Newtonian light time and stellar
aberration corrections.
'XLT' "Transmission" case: correct for
one-way light time using a Newtonian
formulation.
'XLT+S' "Transmission" case: correct for
one-way light time and stellar
aberration using a Newtonian
formulation.
'XCN' "Transmission" case: converged
Newtonian light time correction.
'XCN+S' "Transmission" case: converged
Newtonian light time and stellar
aberration corrections.
The 'abcorr' string lacks sensitivity to case, and to embedded,
leading and trailing blanks.
obsrvr the name of the observing body. Optionally, you
may supply the ID code of the object as an integer
string. For example, both 'EARTH' and '399' are
legitimate strings to supply to indicate the
observer is Earth.
[1,c5] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
dref the name of the reference frame corresponding
to 'dvec'.
[1,c6] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
The 'dref' string lacks sensitivity to case, and to leading
and trailing blanks.
dvec the pointing or boresight 3-vector from the observer. The
intercept of this vector and target is the event of interest.
[3,1] = size(dvec); double = class(dvec)
crdsys the name of the coordinate system for which the
coordinate of interest is a member.
[1,c7] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
coord the name of the coordinate of interest in 'crdsys'.
[1,c8] = size(obsrvr); char = class(obsrvr)
or
[1,1] = size(obsrvr); cell = class(obsrvr)
The supported coordinate systems and coordinate names are:
Coordinate System (crdsys) Coordinates (coord) Range
'RECTANGULAR' 'X'
'Y'
'Z'
'LATITUDINAL' 'RADIUS'
'LONGITUDE' (-Pi,Pi]
'LATITUDE' [-Pi/2,Pi/2]
'RA/DEC' 'RANGE'
'RIGHT ASCENSION' [0,2Pi)
'DECLINATION' [-Pi/2,Pi/2]
'SPHERICAL' 'RADIUS'
'COLATITUDE' [0,Pi]
'LONGITUDE' (-Pi,Pi]
'CYLINDRICAL' 'RADIUS'
'LONGITUDE' [0,2Pi)
'Z'
'GEODETIC' 'LONGITUDE' (-Pi,Pi]
'LATITUDE' [-Pi/2,Pi/2]
'ALTITUDE'
'PLANETOGRAPHIC' 'LONGITUDE' [0,2Pi)
'LATITUDE' [-Pi/2,Pi/2]
'ALTITUDE'
The ALTITUDE coordinates have a constant value
of zero +/- roundoff for ellipsoid targets.
Limit searches for coordinate events in the GEODETIC and
PLANETOGRAPHIC coordinate systems to 'target' bodies with
axial symmetry in the equatorial plane, i.e. equality
of the body X and Y radii (oblate or prolate spheroids).
relate the constraint relational operator on the selected coordinate
of the surface intercept vector. The result window found by
this routine indicates the time intervals where the constraint
is satisfied.
[1,c8] = size(relate); char = class(relate)
or
[1,1] = size(relate); cell = class(relate)
Supported values of relate and corresponding meanings are
shown below:
'>' Separation is greater than the reference
value refval.
'=' Separation is equal to the reference
value refval.
'<' Separation is less than the reference
value refval.
'ABSMAX' Separation is at an absolute maximum.
'ABSMIN' Separation is at an absolute minimum.
'LOCMAX' Separation is at a local maximum.
'LOCMIN' Separation is at a local minimum.
The caller may indicate that the region of interest
is the set of time intervals where the quantity is
within a specified measure of an absolute extremum.
The argument 'adjust' (described below) is used to
specify this measure.
Local extrema are considered to exist only in the
interiors of the intervals comprising the confinement
window: a local extremum cannot exist at a boundary
point of the confinement window.
The 'relate' string lacks sensitivity to case, and to leading
and trailing blanks.
refval reference value used together with 'relate' argument to define
an equality or inequality to satisfy by the selected
coordinate of the surface intercept vector. See the discussion
of 'relate' above for further information.
[1,1] = size(refval); double = class(refval)
The units of 'refval' correspond to the type as defined
by 'coord', radians for angular measures, kilometers for
distance measures.
adjust value used to modify searches for absolute extrema: when
relate is set to ABSMAX or ABSMIN and adjust is set to a
positive value, cspice_gfsntc finds times when the surface
intercept vector coordinate is within 'adjust'
radians/kilometers of the specified extreme value.
[1,1] = size(adjust); double = class(adjust)
For relate set to ABSMAX, the result window contains
time intervals when the surface intercept vector coordinate has
values between ABSMAX - 'adjust' and ABSMAX.
For relate set to ABSMIN, the result window contains
time intervals when the surface intercept vector coordinate has
values between ABSMIN and ABSMIN + 'adjust'.
'adjust' is not used for searches for local extrema,
equality or inequality conditions.
step time step size to use in the search.
[1,1] = size(adjust); double = class(adjust)
Selection of the time step for surface intercept geometry
requires consideration of the mechanics of a surface intercept
event. In most cases, two distinct searches will be needed,
one to determine the windows when the boresight vector
intercepts the surface and then the search based on the user
defined constraints within those windows. The boresight of
nadir pointing instrument may continually intercept a body, but
an instrument scanning across a disc will have configurations
when the boresight does not intercept the body.
The step size must be smaller than the shortest interval
within the confinement window over which the intercept exists
and also smaller than the shortest interval over which the
intercept does not exist.
For coordinates other than LONGITUDE and RIGHT ASCENSION,
the step size must be shorter than the shortest interval,
within the confinement window, over which the coordinate
is monotone increasing or decreasing.
For LONGITUDE and RIGHT ASCENSION, the step size must
be shorter than the shortest interval, within the
confinement window, over which either the sin or cos
of the coordinate is monotone increasing or decreasing.
The choice of 'step' affects the completeness but not
the precision of solutions found by this routine; the
precision is controlled by the convergence tolerance.
See the discussion of the parameter SPICE_GF_CNVTOL for
details.
'step' has units of TDB seconds.
nintvls value specifying the number of intervals in the internal
workspace array used by this routine. 'nintvls' should be at
least as large as the number of intervals within the search
region on which the specified observer-target vector coordinate
function is monotone increasing or decreasing. It does no harm
to pick a value of 'nintvls' larger than the minimum required
to execute the specified search, but if chosen too small, the
search will fail.
[1,1] = size(nintvls); int32 = class(nintvls)
cnfine a SPICE window that confines the time period over which the
specified search is conducted. 'cnfine' may consist of a
single interval or a collection of intervals.
[2m,1] = size(cnfine); double = class(cnfine)
In some cases the confinement window can be used to
greatly reduce the time period that must be searched
for the desired solution. See the Particulars section
below for further discussion.
See the Examples section below for a code example
that shows how to create a confinement window.
the call:
result = cspice_gfsntc( target, fixref, method, abcorr, obsrvr, ...
dref, dvec, crdsys, coord, relate, ...
refval, adjust, step, nintvls, cnfine )
returns:
result the SPICE window of intervals, contained within the
confinement window 'cnfine', on which the specified
constraint is satisfied.
[2n,1] = size(result); double = class(result)
If the search is for local extrema, or for absolute
extrema with adjust set to zero, then normally each
interval of result will be a singleton: the left and
right endpoints of each interval will be identical.
If no times within the confinement window satisfy the
constraint, 'result' will return with cardinality zero.
Any numerical results shown for this example may differ between
platforms as the results depend on the SPICE kernels used as input
and the machine specific arithmetic implementation.
The examples shown below require a frames kernel defining a
a dynamic frame, Sun-Earth Motion. The frame defined by the
sun-to-earth direction vector as the X axis. The Y axis in the
earth orbital plane, and Z completing the right hand system.
We name this frames kernel "sem.tf".
\begindata
FRAME_SEM = 10100000
FRAME_10100000_NAME = 'SEM'
FRAME_10100000_CLASS = 5
FRAME_10100000_CLASS_ID = 10100000
FRAME_10100000_CENTER = 10
FRAME_10100000_RELATIVE = 'J2000'
FRAME_10100000_DEF_STYLE = 'PARAMETERIZED'
FRAME_10100000_FAMILY = 'TWO-VECTOR'
FRAME_10100000_PRI_AXIS = 'X'
FRAME_10100000_PRI_VECTOR_DEF = 'OBSERVER_TARGET_POSITION'
FRAME_10100000_PRI_OBSERVER = 'SUN'
FRAME_10100000_PRI_TARGET = 'EARTH'
FRAME_10100000_PRI_ABCORR = 'NONE'
FRAME_10100000_SEC_AXIS = 'Y'
FRAME_10100000_SEC_VECTOR_DEF = 'OBSERVER_TARGET_VELOCITY'
FRAME_10100000_SEC_OBSERVER = 'SUN'
FRAME_10100000_SEC_TARGET = 'EARTH'
FRAME_10100000_SEC_ABCORR = 'NONE'
FRAME_10100000_SEC_FRAME = 'J2000'
Example(1):
Find the time during 2007 for which the latitude of the
intercept point of the vector pointing from the sun towards
the earth in the IAU_EARTH frame equals zero i.e. the intercept
point crosses the equator.
MAXWIN = 1000;
TIMFMT = 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND';
DVEC = [ 1.; 0.; 0. ];
%
% Load kernels.
%
cspice_furnsh( 'standard.tm' );
cspice_furnsh( 'sem.tf' );
%
% Store the time bounds of our search interval in
% the cnfine confinement window.
%
et = cspice_str2et( { '2007 JAN 01', '2008 JAN 01'} );
cnfine = cspice_wninsd( et(1), et(2) );
%
% The latitude varies relatively slowly (46 degrees) during the
% year. The extrema occur approximately every six months.
% Search using a step size less than half that value (180 days).
% For this example use eighty days (in units of seconds).
%
step = cspice_spd*80.;
%
% Perform four searches to determine the times when the latitude-
% longitude box restriction conditions apply to the subpoint vector.
%
% Use geodetic coordinates.
%
adjust = 0.;
adjust = 0.D0;
refval = 0.D0;
target = 'EARTH';
obsrvr = 'SUN';
dref = 'SEM';
method = 'Ellipsoid';
fixref = 'IAU_EARTH';
crdsys = 'LATITUDINAL';
coord = 'LATITUDE';
relate = '=';
nintvls= MAXWIN;
%
% Use the same aberration correction flag as that in the SEM frame
% definition.
%
abcorr = 'NONE';
result = cspice_gfsntc( target, fixref, method, abcorr, obsrvr, ...
dref, DVEC, crdsys, coord, relate, ...
refval, adjust, step, nintvls, cnfine );
%
% List the beginning and ending times in each interval
% if 'result' contains data.
%
for i=1:numel(result)/2
[left, right] = cspice_wnfetd( result, i );
output = cspice_timout( [left,right], TIMFMT );
if( isequal( left, right) )
disp( ['Event time: ' output(1,:)] )
else
disp( ['From : ' output(1,:)] )
disp( ['To : ' output(2,:)] )
disp( ' ' );
end
end
%
% It's always good form to unload kernels after use,
% particularly in Matlab due to data persistence.
%
cspice_kclear
MATLAB outputs:
Event time: 2007-MAR-21 00:01:25.495121 (TDB)
Event time: 2007-SEP-23 09:46:39.574123 (TDB)
Example(2):
Find the time during 2007 for which the intercept point on the
earth of the sun-to-earth vector as described in Example 1 in
the IAU_EARTH frame lies within a geodetic latitude-longitude
"box" defined as
16 degrees <= latitude <= 17 degrees
85 degrees <= longitude <= 86 degrees
This problem requires four searches, each search on one of the
box restrictions. The user needs also realize the temporal behavior
of latitude greatly differs from that of the longitude. The
the intercept latitude varies between approximately 23.44 degrees
and -23.44 degrees during the year. The intercept longitude varies
between -180 degrees and 180 degrees in one solar day.
MAXWIN = 1000;
TIMFMT = 'YYYY-MON-DD HR:MN:SC.###### (TDB) ::TDB ::RND';
DVEC = [ 1.; 0.; 0. ];
%
% Load kernels.
%
cspice_furnsh( 'standard.tm' );
cspice_furnsh( 'sem.tf' );
%
% Store the time bounds of our search interval in
% the cnfine confinement window.
%
et = cspice_str2et( { '2007 JAN 01', '2008 JAN 01'} );
cnfine = cspice_wninsd( et(1), et(2) );
%
% The latitude varies relatively slowly (46 degrees) during the
% year. The extrema occur approximately every six months.
% Search using a step size less than half that value (180 days).
% For this example use ninety days (in units of seconds).
%
step = cspice_spd*90.;
%
% Perform four searches to determine the times when the latitude-
% longitude box restriction conditions apply to the subpoint vector.
%
% Use geodetic coordinates.
%
adjust = 0.;
target = 'EARTH';
obsrvr = 'SUN';
dref = 'SEM';
method = 'Ellipsoid';
fixref = 'IAU_EARTH';
crdsys = 'GEODETIC';
nintvls= MAXWIN;
%
% Use the same aberration correction flag as that in the SEM frame
% definition.
%
abcorr = 'NONE';
%
% Perform the searches such that the result window of a search
% serves as the confinement window of the subsequent search.
%
%
% Since the latitude coordinate varies slowly and is well behaved
% over the time of the confinement window, search first for the
% windows satisfying the latitude requirements, then use that result
% as confinement for the longitude search.
%
coord = 'LATITUDE';
refval = 16. * cspice_rpd;
relate = '>';
%
% Perform this search using the geometric position
% of the bodies; set the aberration correction to 'NONE'.
%
result1 = cspice_gfsntc( target, fixref, method, abcorr, obsrvr, ...
dref, DVEC, crdsys, coord, relate, refval, ...
adjust, step, nintvls, cnfine );
refval = 17. * cspice_rpd;
relate = '<';
result2 = cspice_gfsntc( target, fixref, method, abcorr, obsrvr, ...
dref, DVEC, crdsys, coord, relate, refval, ...
adjust, step, nintvls, result1 );
%
% Now the longitude search.
%
coord = 'LONGITUDE';
%
% Reset the step size to something appropriate for the 360
% degrees in 24 hours domain. The longitude shows near
% linear behavior so use a step size less than half the period
% of twelve hours. Ten hours will suffice in this case.
%
step = cspice_spd * (10./24.);
refval = 85. * cspice_rpd;
relate = '>';
result3 = cspice_gfsntc( target, fixref, method, abcorr, obsrvr, ...
dref, DVEC, crdsys, coord, relate, refval, ...
adjust, step, nintvls, result2 );
%
% Contract the endpoints of each window to account
% for possible round-off error at the -180/180 degree branch.
%
% A contraction value of a millisecond should eliminate
% any round-off caused branch crossing.
%
result3 = cspice_wncond( 1e-3, 1e-3, result3 );
refval = 86. * cspice_rpd;
relate = '<';
result4 = cspice_gfsntc( target, fixref, method, abcorr, obsrvr, ...
dref, DVEC, crdsys, coord, relate, refval, ...
adjust, step, nintvls, result3 );
%
% List the beginning and ending times in each interval
% if result contains data.
%
result = result4;
for i=1:numel(result)/2
[left, right] = cspice_wnfetd( result, i );
output = cspice_timout( [left,right], TIMFMT );
if( isequal( left, right) )
disp( ['Event time: ' output(1,:)] )
else
disp( ['From : ' output(1,:)] )
disp( ['To : ' output(2,:)] )
fprintf( '\n' );
end
end
%
% It's always good form to unload kernels after use,
% particularly in Matlab due to data persistence.
%
cspice_kclear
MATLAB outputs:
From : 2007-MAY-05 06:14:04.637735 (TDB)
To : 2007-MAY-05 06:18:03.621907 (TDB)
From : 2007-MAY-06 06:13:59.583483 (TDB)
To : 2007-MAY-06 06:17:58.569240 (TDB)
From : 2007-MAY-07 06:13:55.102940 (TDB)
To : 2007-MAY-07 06:17:54.090299 (TDB)
From : 2007-AUG-06 06:23:17.282927 (TDB)
To : 2007-AUG-06 06:27:16.264010 (TDB)
From : 2007-AUG-07 06:23:10.545441 (TDB)
To : 2007-AUG-07 06:27:09.524925 (TDB)
From : 2007-AUG-08 06:23:03.233996 (TDB)
To : 2007-AUG-08 06:27:02.211889 (TDB)
From : 2007-AUG-09 06:22:55.351256 (TDB)
To : 2007-AUG-09 06:26:54.327566 (TDB)
This routine provides a simple interface for conducting searches
for surface intercept vector coordinate value events.
This routine determines a set of one or more time intervals
within the confinement window when the selected coordinate of
the surface intercept vector satisfies a caller-specified
constraint. The resulting set of intervals is returned as a SPICE
window.
Below we discuss in greater detail aspects of this routine's
solution process that are relevant to correct and efficient
use of this routine in user applications.
The Search Process
==================
Regardless of the type of constraint selected by the caller, this
routine starts the search for solutions by determining the time
periods, within the confinement window, over which the specified
coordinate function is monotone increasing and monotone
decreasing. Each of these time periods is represented by a SPICE
window. Having found these windows, all of the coordinate
function's local extrema within the confinement window are known.
Absolute extrema then can be found very easily.
Within any interval of these "monotone" windows, there will be at
most one solution of any equality constraint. Since the boundary
of the solution set for any inequality constraint is contained in
the union of
- the set of points where an equality constraint is met
- the boundary points of the confinement window
the solutions of both equality and inequality constraints can be
found easily once the monotone windows have been found.
Step Size
=========
The monotone windows (described above) are found using a two-step
search process. Each interval of the confinement window is
searched as follows: first, the input step size is used to
determine the time separation at which the sign of the rate of
change of coordinate will be sampled. Starting at
the left endpoint of an interval, samples will be taken at each
step. If a change of sign is found, a root has been bracketed; at
that point, the time at which the time derivative of the coordinate
is zero can be found by a refinement process, for example,
using a binary search.
Note that the optimal choice of step size depends on the lengths
of the intervals over which the coordinate function is monotone:
the step size should be shorter than the shortest of these
intervals (within the confinement window).
The optimal step size is *not* necessarily related to the lengths
of the intervals comprising the result window. For example, if
the shortest monotone interval has length 10 days, and if the
shortest result window interval has length 5 minutes, a step size
of 9.9 days is still adequate to find all of the intervals in the
result window. In situations like this, the technique of using
monotone windows yields a dramatic efficiency improvement over a
state-based search that simply tests at each step whether the
specified constraint is satisfied. The latter type of search can
miss solution intervals if the step size is longer than the
shortest solution interval.
Having some knowledge of the relative geometry of the target and
observer can be a valuable aid in picking a reasonable step size.
In general, the user can compensate for lack of such knowledge by
picking a very short step size; the cost is increased computation
time.
Note that the step size is not related to the precision with which
the endpoints of the intervals of the result window are computed.
That precision level is controlled by the convergence tolerance.
Convergence Tolerance
=====================
As described above, the root-finding process used by this routine
involves first bracketing roots and then using a search process
to locate them. "Roots" are both times when local extrema are
attained and times when the distance function is equal to a
reference value. All endpoints of the intervals comprising the
result window are either endpoints of intervals of the
confinement window or roots.
Once a root has been bracketed, a refinement process is used to
narrow down the time interval within which the root must lie.
This refinement process terminates when the location of the root
has been determined to within an error margin called the
"convergence tolerance." The convergence tolerance used by this
routine is set by the parameter SPICE_GF_CNVTOL.
The value of SPICE_GF_CNVTOL is set to a "tight" value so that the
tolerance doesn't become the limiting factor in the accuracy of
solutions found by this routine. In general the accuracy of input
data will be the limiting factor.
The user may change the convergence tolerance from the default
SPICE_GF_CNVTOL value by calling the routine cspice_gfstol, e.g.
cspice_gfstol( tolerance value in seconds )
Call cspice_gfstol prior to calling this routine. All subsequent
searches will use the updated tolerance value.
Setting the tolerance tighter than SPICE_GF_CNVTOL is unlikely to be
useful, since the results are unlikely to be more accurate.
Making the tolerance looser will speed up searches somewhat,
since a few convergence steps will be omitted. However, in most
cases, the step size is likely to have a much greater affect on
processing time than would the convergence tolerance.
The Confinement Window
======================
The simplest use of the confinement window is to specify a time
interval within which a solution is sought. However, the
confinement window can, in some cases, be used to make searches
more efficient. Sometimes it's possible to do an efficient search
to reduce the size of the time period over which a relatively
slow search of interest must be performed.
Practical use of the coordinate search capability would likely
consist of searches over multiple coordinate constraints to find
time intervals that satisfies the constraints. An effective
technique to accomplish such a search is to use the result
window from one search as the confinement window of the next.
Longitude and Right Ascension
=============================
The cyclic nature of the longitude and right ascension coordinates
produces branch cuts at +/- 180 degrees longitude and 0-360
longitude. Round-off error may cause solutions near these branches
to cross the branch. Use of the SPICE routine cspice_wncond will contract
solution windows by some epsilon, reducing the measure of the
windows and eliminating the branch crossing. A one millisecond
contraction will in most cases eliminate numerical round-off caused
branch crossings.
For important details concerning this module's function, please refer to
the CSPICE routine gfsntc_c.
MICE.REQ
GF.REQ
SPK.REQ
CK.REQ
TIME.REQ
WINDOWS.REQ
-Mice Version 1.0.2, 18-NOV-2014, EDW (JPL)
Edited I/O section to conform to NAIF standard for Mice documentation.
-Mice Version 1.0.1, 05-SEP-2012, EDW (JPL)
Edit to comments to correct search description.
Edits to and corrections of argument descriptions and
header.
Header updated to describe use of cspice_gfstol.
-Mice Version 1.0.0, 15-APR-2009, EDW (JPL)
GF surface intercept coordinate search
|


$ git checkout -b <branch> --track <remote>/<branch>
git-checkout(1) Manual Page
NAME
git-checkout - Checkout a branch or paths to the working tree
SYNOPSIS
git checkout [-q] [-f] [-m] [<branch>] git checkout [-q] [-f] [-m] --detach [<branch>] git checkout [-q] [-f] [-m] [--detach] <commit> git checkout [-q] [-f] [-m] [[-b|-B|--orphan] <new_branch>] [<start_point>] git checkout [-f|--ours|--theirs|-m|--conflict=<style>] [<tree-ish>] [--] <paths>... git checkout [-p|--patch] [<tree-ish>] [--] [<paths>...]
DESCRIPTION
Updates files in the working tree to match the version in the index or the specified tree. If no paths are given, git checkout will also update HEAD to set the specified branch as the current branch.
- git checkout <branch>
To prepare for working on <branch>, switch to it by updating the index and the files in the working tree, and by pointing HEAD at the branch. Local modifications to the files in the working tree are kept, so that they can be committed to the <branch>.
If <branch> is not found but there does exist a tracking branch in exactly one remote (call it <remote>) with a matching name, treat as equivalent to
You could omit <branch>, in which case the command degenerates to "check out the current branch", which is a glorified no-op with a rather expensive side-effects to show only the tracking information, if exists, for the current branch.
- git checkout -b|-B <new_branch> [<start point>]
Specifying -b causes a new branch to be created as if git-branch(1) were called and then checked out. In this case you can use the --track or --no-track options, which will be passed to git branch. As a convenience, --track without -b implies branch creation; see the description of --track below.
If -B is given, <new_branch> is created if it doesn't exist; otherwise, it is reset. This is the transactional equivalent of
$ git branch -f <branch> [<start point>] $ git checkout <branch>
that is to say, the branch is not reset/created unless "git checkout" is successful.
- git checkout --detach [<branch>]
- git checkout [--detach] <commit>
Prepare to work on top of <commit>, by detaching HEAD at it (see "DETACHED HEAD" section), and updating the index and the files in the working tree. Local modifications to the files in the working tree are kept, so that the resulting working tree will be the state recorded in the commit plus the local modifications.
When the <commit> argument is a branch name, the --detach option can be used to detach HEAD at the tip of the branch (git checkout <branch> would check out that branch without detaching HEAD).
Omitting <branch> detaches HEAD at the tip of the current branch.
- git checkout [-p|--patch] [<tree-ish>] [--] <pathspec>...
When <paths> or --patch are given, git checkout does not switch branches. It updates the named paths in the working tree from the index file or from a named <tree-ish> (most often a commit). In this case, the -b and --track options are meaningless and giving either of them results in an error. The <tree-ish> argument can be used to specify a specific tree-ish (i.e. commit, tag or tree) to update the index for the given paths before updating the working tree.
The index may contain unmerged entries because of a previous failed merge. By default, if you try to check out such an entry from the index, the checkout operation will fail and nothing will be checked out. Using -f will ignore these unmerged entries. The contents from a specific side of the merge can be checked out of the index by using --ours or --theirs. With -m, changes made to the working tree file can be discarded to re-create the original conflicted merge result.
OPTIONS
- -q
- --quiet
Quiet, suppress feedback messages.
- -f
- --force
When switching branches, proceed even if the index or the working tree differs from HEAD. This is used to throw away local changes.
When checking out paths from the index, do not fail upon unmerged entries; instead, unmerged entries are ignored.
- --ours
- --theirs
When checking out paths from the index, check out stage #2 (ours) or #3 (theirs) for unmerged paths.
- -b <new_branch>
Create a new branch named <new_branch> and start it at <start_point>; see git-branch(1) for details.
- -B <new_branch>
Creates the branch <new_branch> and start it at <start_point>; if it already exists, then reset it to <start_point>. This is equivalent to running "git branch" with "-f"; see git-branch(1) for details.
- -t
- --track
When creating a new branch, set up "upstream" configuration. See "--track" in git-branch(1) for details.
If no -b option is given, the name of the new branch will be derived from the remote-tracking branch, by looking at the local part of the refspec configured for the corresponding remote, and then stripping the initial part up to the "*". This would tell us to use "hack" as the local branch when branching off of "origin/hack" (or "remotes/origin/hack", or even "refs/remotes/origin/hack"). If the given name has no slash, or the above guessing results in an empty name, the guessing is aborted. You can explicitly give a name with -b in such a case.
- --no-track
Do not set up "upstream" configuration, even if the branch.autosetupmerge configuration variable is true.
- -l
Create the new branch's reflog; see git-branch(1) for details.
- --detach
Rather than checking out a branch to work on it, check out a commit for inspection and discardable experiments. This is the default behavior of "git checkout <commit>" when <commit> is not a branch name. See the "DETACHED HEAD" section below for details.
- --orphan <new_branch>
Create a new orphan branch, named <new_branch>, started from <start_point> and switch to it. The first commit made on this new branch will have no parents and it will be the root of a new history totally disconnected from all the other branches and commits.
The index and the working tree are adjusted as if you had previously run "git checkout <start_point>". This allows you to start a new history that records a set of paths similar to <start_point> by easily running "git commit -a" to make the root commit.
This can be useful when you want to publish the tree from a commit without exposing its full history. You might want to do this to publish an open source branch of a project whose current tree is "clean", but whose full history contains proprietary or otherwise encumbered bits of code.
If you want to start a disconnected history that records a set of paths that is totally different from the one of <start_point>, then you should clear the index and the working tree right after creating the orphan branch by running "git rm -rf ." from the top level of the working tree. Afterwards you will be ready to prepare your new files, repopulating the working tree, by copying them from elsewhere, extracting a tarball, etc.
- --ignore-skip-worktree-bits
In sparse checkout mode, git checkout -- <paths> would update only entries matched by <paths> and sparse patterns in $GIT_DIR/info/sparse-checkout. This option ignores the sparse patterns and adds back any files in <paths>.
- -m
- --merge
When switching branches, if you have local modifications to one or more files that are different between the current branch and the branch to which you are switching, the command refuses to switch branches in order to preserve your modifications in context. However, with this option, a three-way merge between the current branch, your working tree contents, and the new branch is done, and you will be on the new branch.
When a merge conflict happens, the index entries for conflicting paths are left unmerged, and you need to resolve the conflicts and mark the resolved paths with git add (or git rm if the merge should result in deletion of the path).
When checking out paths from the index, this option lets you recreate the conflicted merge in the specified paths.
- --conflict=<style>
The same as --merge option above, but changes the way the conflicting hunks are presented, overriding the merge.conflictstyle configuration variable. Possible values are "merge" (default) and "diff3" (in addition to what is shown by "merge" style, shows the original contents).
- -p
- --patch
Interactively select hunks in the difference between the <tree-ish> (or the index, if unspecified) and the working tree. The chosen hunks are then applied in reverse to the working tree (and if a <tree-ish> was specified, the index).
This means that you can use git checkout -p to selectively discard edits from your current working tree. See the Interactive Mode section of git-add(1) to learn how to operate the --patch mode.
- <branch>
Branch to checkout; if it refers to a branch (i.e., a name that, when prepended with "refs/heads/", is a valid ref), then that branch is checked out. Otherwise, if it refers to a valid commit, your HEAD becomes "detached" and you are no longer on any branch (see below for details).
As a special case, the "@{-N}" syntax for the N-th last branch checks out the branch (instead of detaching). You may also specify - which is synonymous with "@{-1}".
As a further special case, you may use "A...B" as a shortcut for the merge base of A and B if there is exactly one merge base. You can leave out at most one of A and B, in which case it defaults to HEAD.
- <new_branch>
Name for the new branch.
- <start_point>
The name of a commit at which to start the new branch; see git-branch(1) for details. Defaults to HEAD.
- <tree-ish>
Tree to checkout from (when paths are given). If not specified, the index will be used.
DETACHED HEAD
HEAD normally refers to a named branch (e.g. master). Meanwhile, each branch refers to a specific commit. Let's look at a repo with three commits, one of them tagged, and with branch master checked out:
HEAD (refers to branch 'master') | v a---b---c branch 'master' (refers to commit 'c') ^ | tag 'v2.0' (refers to commit 'b')
When a commit is created in this state, the branch is updated to refer to the new commit.    This is known as being in detached HEAD state. It means simply that HEAD refers to a specific commit, as opposed to referring to a named branch.     If we have not yet moved away from commit f, any of these will create a reference to it:
$ git checkout -b foo <1> $ git branch foo <2> $ git tag foo <3>
creates a new branch foo, which refers to commit f, and then updates HEAD to refer to branch foo. In other words, we'll no longer be in detached HEAD state after this command.
similarly creates a new branch foo, which refers to commit f, but leaves HEAD detached.
creates a new tag foo, which refers to commit f, leaving HEAD detached.
If we have moved away from commit f, then we must first recover its object name (typically by using git reflog), and then we can create a reference to it. For example, to see the last two commits to which HEAD referred, we can use either of these commands:
$ git reflog -2 HEAD # or $ git log -g -2 HEAD
EXAMPLES
The following sequence checks out the master branch, reverts the Makefile to two revisions back, deletes hello.c by mistake, and gets it back from the index.
$ git checkout master <1> $ git checkout master~2 Makefile <2> $ rm -f hello.c $ git checkout hello.c <3>
switch branch
take a file out of another commit
restore hello.c from the index
If you want to check out all C source files out of the index, you can say
$ git checkout -- '*.c'
Note the quotes around *.c. The file hello.c will also be checked out, even though it is no longer in the working tree, because the file globbing is used to match entries in the index (not in the working tree by the shell).
If you have an unfortunate branch that is named hello.c, this step would be confused as an instruction to switch to that branch. You should instead write:
$ git checkout -- hello.c
After working in the wrong branch, switching to the correct branch would be done using:
$ git checkout mytopic
However, your "wrong" branch and correct "mytopic" branch may differ in files that you have modified locally, in which case the above checkout would fail like this:
$ git checkout mytopic error: You have local changes to 'frotz'; not switching branches.
You can give the -m flag to the command, which would try a three-way merge:
$ git checkout -m mytopic Auto-merging frotz
After this three-way merge, the local modifications are not registered in your index file, so git diff would show you what changes you made since the tip of the new branch.
When a merge conflict happens during switching branches with the -m option, you would see something like this:
$ git checkout -m mytopic Auto-merging frotz ERROR: Merge conflict in frotz fatal: merge program failed
At this point, git diff shows the changes cleanly merged as in the previous example, as well as the changes in the conflicted files. Edit and resolve the conflict and mark it resolved with git add as usual:
$ edit frotz $ git add frotz
GIT
Part of the git(1) suite


Toggle navigation
Vax Trends
Home
Coverage
VPD Rates
Immunization Schedule
Data Sources
{% block content %} {% endblock %}