The script: 1) suspend capturing images at night for obvious reason
and 2) writes images to files named as:
image_<odd-or-even-week><day-of-week>_<hour><minute>.jpg
Thus only images from the last two weeks are stored and the older ones are deleted ``automatically''.
#!/bin/bash OUTPUT_DIR=/var/www/cam/fswebcam-output # Max resolution for C270 webcam is 1280x720 RESOLUTION="1280x720" QUALITY="85" MINUTE=`date +%M` HOUR=`date +%H` MONTH=`date +%m` DAY_OF_WEEK=`date +%u` WEEK=`date +%U` FILE_OUT=`date +%d%H%M` TODAY=`date +%Y/%m/%d` ## Suspend capturing pictures at night DAY_START=`sun_calc.py -date "$TODAY" -city Sopot -param dawn` DAY_STOP=`sun_calc.py -date "$TODAY" -city Sopot -param dusk` if [ "$DAY_START" = "False" -o "$DAY_STOP" = "True" ] ; then NIGHT="YES"; exit; fi fswebcam -r $RESOLUTION -S 11 --jpeg $QUALITY \ --title "Sopot/Abrahama Street (PL)" \ --subtitle "View from my window" \ --info "Logitech_Webcam_C270@raspberryPi ($RESOLUTION)" \ --save $OUTPUT_DIR/image.jpg -q ## Rotate photos every two weeks ## Week number modulo 2 (0 or 1) WEEK_NO=$(($WEEK % 2)) FILE_OUT="${WEEK_NO}${DAY_OF_WEEK}_$HOUR$MINUTE" ## Wundergound expects the file is `image.jpg'. ## To preserve from overwriting rename: cd $OUTPUT_DIR && cp image.jpg image_$FILE_OUT.jpg
./sun_calc.py
is a Python script (I am not
Python programmer BTW):
#!/usr/bin/python import datetime import argparse import pytz from astral import Astral city_name = 'Sopot' parser = argparse.ArgumentParser() parser.add_argument("-date", type=str, help="Date as yyyy/mm/dd") parser.add_argument("-city", type=str, help="City name") parser.add_argument("-param", type=str, help="dusk sunrise sunset or dawn") parser.add_argument("-verbose", help="Icrease verbosity", action="store_true") args = parser.parse_args() dat = args.date city_name = args.city param = args.param verb_level = args.verbose [year, month, day] = dat.split("/"); year = int(year) month = int(month) day = int(day) a = Astral() city = a[city_name] a.solar_depression = 6 ## sd can be: 6, 12, 18 timezone = city.timezone sun = city.sun(date=datetime.date(year, month, day), local=False) sun_local = city.sun(date=datetime.date(year, month, day), local=True) time_now = datetime.datetime.utcnow().replace(tzinfo = pytz.utc) if verb_level > 0: print('solar_depressions: ' + str(a.solar_depression)) print city_name + " " + str(time_now) + " " + str(sun[param]) \ + " (" + str(sun_local[param]) + ")" print time_now > sun[param]
The script based on astral
package can compute
dusk/dawn time (among other things) and compares it to the current time.
If current time is past dusk/dawn (specified as a command line parameter)
./sun_calc.py
returns True
.
Otherwise it returns False
.
The astral
package does not contains Sopot but it is easy
to add it just
by editing astral.py
(before installation of course):
Sopot,Poland,54°44'N,18°55'E,Europe/Warsaw
A short test demonstrating that for Sopot and Warsow the script returns significantly different results:
./sun_calc.py -date 2013/01/21 -city Sopot -param dawn -verbose solar_depressions: 6.0 Sopot 2013-01-21 09:17:11.368979+00:00 2013-01-21 06:09:47+00:00 (2013-01-21 07:09:47+01:00) ./sun_calc.py -date 2013/01/21 -city Warsaw -param dawn -verbose solar_depressions: 6.0 Warsaw 2013-01-21 09:17:46.172157+00:00 2013-01-21 05:53:22+00:00 (2013-01-21 06:53:22+01:00) True
So there is circa 15 minutes difference between Sopot which is some 300 km to the North from Warsaw.
Yesterday I have got a letter containing BMP085 pressure sensor which I bought on ebay on November 20th 2012 (yes the post made a history with +50 days delivery from China).
To connect BMP085 to RPI first one has to install (in case both packages are not installed yet):
pi@raspberrystar ~ $ sudo apt-get install i2c-tools pi@raspberrystar ~ $ sudo apt-get install python-smbus
Now one has to enable i2c in raspbian. First one has to add the user pi to the group i2c:
pi@raspberrystar ~ $ sudo adduser pi i2c
Next one has to check the contents of
/etc/modprobe.d/raspi-blacklist.conf
and /etc/modules
:
pi@raspberrystar ~ $ less /etc/modprobe.d/raspi-blacklist.conf # blacklist spi and i2c by default (many users don't need them) blacklist spi-bcm2708 blacklist i2c-bcm2708 pi@raspberrystar ~ $ less /etc/modules ... i2c-dev i2c-bcm2708
Some users advocate to remove i2c-bcm2708 from blacklisted modules but this seems unneccessary as:
pi@raspberrystar ~ $ lsmod | grep i2c i2c_bcm2708 3542 0 i2c_dev 5587 0
so I have i2c_bcm270
w/o modifying
/etc/modprobe.d/raspi-blacklist.conf
Reboot now to activate the new settings
The board my sensor came on has eight pins. There are boards
with 6 pins as well which seems to be more popular.
Only four out of 8 pins are used and the connections
are as follows (see pictures):
GND goes to Ground on the Pi (P1-05)
3.3 goes to 3V3 on the Pi (P1-01)
SDA goes to SDA on the Pi (P1-02)
SCL goes to SCL on the Pi (P1-03)
In Reading data from a Bosch BMP085 with a Raspberry Pi 6-ping sensor is used and the pins connections are different. I have tried but it does not work for my sensor.
I connect sensor to RPI using wires with female jumpers on both ends.
To check if the sensor (or other i2c device) is connected correctly,
one can run i2cdetect
:
pi@raspberrystar ~ $ i2cdetect -y 0 0 1 2 3 4 5 6 7 8 9 a b c d e f 00: -- -- -- -- -- -- -- -- -- -- -- -- -- 10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- 70: -- -- -- -- -- -- -- 77
77 in the last row indicates that sensor is connected properly (otherwise the output will consists of rows of '--' only).
To get data from the sensor one has to install Adafruit-Raspberry-Pi-Python-Code or compile small C program available here:
## Download john.geek's C application: wget http://www.john.geek.nz/wp-content/uploads/2012/08/testBMP085.c wget http://www.john.geek.nz/wp-content/uploads/2012/12/smbus.c wget http://www.john.geek.nz/wp-content/uploads/2012/12/smbus.h ## Compile & run it gcc -Wall -o testBMP085 ./smbus.c ./testBMP085.c ./testBMP085 ## Download >Adafruit's one: git clone https://github.com/adafruit/Adafruit-Raspberry-Pi-Python-Code.git cd Adafruit-Raspberry-Pi-Python-Code cd Adafruit_BMP085 ## Run python Adafruit_BMP085_example.py
Note: testBMP085
works with sensor connected to RPi as described in this post
(not as described by
john geek).
BTW: the pressure is identical as reported by my WH 2080 weather station. Perhaphs WH 2080 use exactly the same sensor!
I was asked to help to prepare a paper with Springer's svmult
class.
The conference (held in Germany) organizers refer
to http://www.springer.com/authors/
for formatting instructions but these instructions lack one important detail:
how to format citations and the bibliography listing.
The editor of the conference the paper is to be submitted insists on using author(s) name(s)/publication year (Harvard) system but bibliography listing conformed to Harvard system can be formatted in several pretty different ways.
I have found the following recommendations concerning references
in manuscript-guidelines.pdf
:
One author: (Miller 1991) or Miller (1991)
Two authors: (Miller and Smith 1994) or Miller and Smith (1994)
Three authors or more: (Miller et al. 1995) or Miller et al. (1995)
It is not explained (among other things) however how to format multiple citations, ie:
(Miller and Smith 1994, Jones 2002, Jordan et al. 2004) or
(Miller and Smith 1994; Jones 2002; Jordan et al. 2004)
or in some other way?
To figure out the required bibliography format in desperation
I decided to run bibtex
with spbasic.bst
(included in
svmult
package)
and then I have discovered
a pretty lengthy comment (inside spbasic.bst
)
on using svmult
and Harvard system.
Well documented package :@
.
Neue
Deutsche Wirtschaft?.
The conference organizers were asked if the above is OK. The lack of detailed manuscript guidelines is suspicious (I suspect that person responsible for conference proceedings is not a LaTeX expert) but as they say `OK' the problem seems to be solved.
To save potential users of svmult
reinventing the wheel
in cases as the one described above:-) here is the template of the manuscript:
\documentclass[natbib]{svmult} %% option natbib for author/year bibliography \usepackage{mathptmx} % selects Times Roman as basic font \usepackage{helvet} % selects Helvetica as sans-serif font %% %% cf. manuscript-guidelines-1.0.pdf %% --------------------------------- %% Cite references in the text with author name/s and year of %% publication in parentheses ("Harvard system"): %% One author: (Miller 1991) or Miller (1991) %% Two authors: (Miller and Smith 1994) or Miller and Smith (1994) %% Three authors or more: (Miller et al. 1995) or Miller et al. (1995) %% %% Use the command \bibpunct with one optional and 6 mandatory arguments: %% arg 5 -- the punctuation that comes between the author names and the year %% empty argument denotes space between author-name publication-year \bibpunct{(}{)}{,}{a}{}{,} %% \begin{document} %% %% In English texts all words of a heading (\title, \section, \subsection etc) %% have a leading capital letter except for articles (a, an, the), %% conjunctions and prepositions of up to four letters (e.g. on, of, at, to, etc...) %% (cf cf. authinst.pdf) %% \title*{DC of Data Streaming with~a~GNG Network} % \author{Janina Filipowicz and Tadeusz Owsianko} \institute{Janina Filipowicz \at Casimir Pulaski University of Technology and Humanities in Radom, Higher School of Engineering, \email{filipj@ut-radom.edu.pl} \and Tadeusz Owsianko \at Universitas Technologiae et Humanistica Radomensis Casimirus Pulaski, Faculty of~Materials Science \email{owsianko@ut-radom.edu.pl}} \maketitle \abstract{%% The paper presents the results of simulation research concerning the possibility of applying self-learning GNG neural networks in clustering data from the data streams. %% Keywords are optional \keywords{cluster analysis, data streams clustering, GNGN.} } \section{Introduction} One of the problems connected with the analysis of data [...] \section{Related Work} [...] They may be divided into four basic groups. The first group is made of the incremental or online classifiers. These are such algorithms as the Very Fast Decision Tree algorithm (VFDT)~\citep{domingoshulten2000}. The second group is made of the multi model algorithms such as Ensemble Classifiers (EC)~\citep{wangfan2003,kranenassent2011}. The third group of algorithms contains the low granularity Rule Based Classifier proposed by~\cite{jirayusakulauwatanamongkol2007}. In cluster analysis their applications were studied among others by~\cite{kaufmanrousseeuw1990}, as well as by~\cite{fritzke1994}. In the study presented below, the data grouping algorithm based on the self---learning of neural network of the Growing Neural Gas (GNG) type will be presented. Compared to the classical Fritzke algorithm~\citeyearpar{fritzke1994} it has been substantially modified. \section{Algorithm of a GNG Network} In the study presented the data grouping algorithm based on the self-learning of neural network of the Growing Neural Gas (GNG) type will be presented. Compared to the classical Fritzke algorithm~\citeyearpar{fritzke1994} it has been substantially modified. \section{An Experimental Study} Summing up the results of experiment, it can be said, that the compatibility of grouping with the known model was very high (cf.~table~\ref{t:quality-speed-clusters}). \begin{table}[!tbh] \caption{Quality and speed of learning of~the GNG network\label{t:quality-speed-clusters}} %%\tabcolsep=.7\tabcolsep \begin{tabular}{l|rrrrrrrrrrrrrr} \hline Clusters & 2 & 3 & 4 & 5 & 6 & 15 \\ \hline Mean RAS & 0.75 & 0.92 & 0.97 & 0.98 & 0.99 & 0.83 \\ Mean SC & 0.50 & 0.74 & 0.86 & 0.91 & 0.93 & 0.76 \\ Mean Time/Iter ($s^{-4}$)& 4.08 & 4.20 & 4.29 & 4.31 & 4.35 & 4.51 \\ \hline \end{tabular} \end{table} [...] The time of single learning iteration of the network depends on the number of neurons in that network [...] \section{Concluding Remarks} It is difficult to determine the threshold value at which the network should switch from the dynamic into the static phase. The above mentioned problems will be subject of further research. \begin{thebibliography}{} %% Conference proceedings etc: \bibitem[Domingos and Hulten(2000)]{domingoshulten2000} Domingos P, Hulten G (2000): Mining High-Speed Data Streams. In: Proceedings of the sixth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, Boston, pp~71--80. %% Book 1 author \bibitem[Fritzke(1994)]{fritzke1994} Fritzke B (1994): Growing Cell Structures -- a~Self-Organizing Network for Unsupervised and Supervised Learning. Neural Networks 7:1441--1460. %% Journal article \bibitem[Jirayusakul and Auwatanamongkol(2007)]{jirayusakulauwatanamongkol2007} Jirayusakul A, Auwatanamongkol S (2007): A Supervised Growing Neural Gas Algorithm for Cluster Analysis, International Journal of Hybrid Intelligent Systems 4(2):129--141. %% Book 2 authors \bibitem[Kaufman and Rousseeuw(1990)]{kaufmanrousseeuw1990} Kaufman L, Rousseeuw PJ (1990) Finding Groups in Data: a~Introduction to Cluster Analysis. Wiley, New York. %% Journal article more than 2 authors: \bibitem[Kranen et~al.(2011)]{kranenassent2011} Kranen P, Assent I, Baldauf C, Seidl T (2011) The ClusTree: Indexing Micro-Clusters for Anytime Stream Mining. Knowledge and Information Systems 29(2):249--272. %% Conf proceeding more than 3 authors: \bibitem[Wang et~al.(2003)]{wangfan2003} Wang H, Fan W, Yu PS, HAN J (2003) Mining Concept-Drifting Data Streams Using Ensemble Classifiers. In Proceedings of the ninth ACM SIGKDD International Conference on Knowledge Discovery and Data Mining, NY, pp~226--235. \end{thebibliography} \end{document}
BibTeX is not used. Optional argument of \bibitem
command
should contains text which is used by natbib
to format citations.
This text should looks like: author-list(year).