Thursday, January 7, 2016

Thursday, November 21, 2013

Monthly hours of sunshine maps for Germany



The blog has moved to syngron.com




Monthly sunshine hours in Germany with individual scale.
Monthly sunshine hours in Germany with global scale.

Recently I saw this surprising map comparing the sunshine hours of Europe with the US:

http://www.reddit.com/r/MapPorn/comments/161j95/europe_vs_the_united_states_sunlight_in_hours_per/

Any location in the US apparently has much more sunshine than any location in Germany! Actually this makes sense if you check the latitude boundaries of the US and Europe but it was never that clear to me.

This made me wonder how the distribution is in Germany and there are already a couple of maps done for that which are easily found with a fast internet search.

But then I stumbled upon some nice datasets from the German Weather Service (DWD, Deutscher Wetterdienst). They actually provide monthly raw data of sunshine hours for all of their weather stations online :

Free weather data from the DWD (mean data of 30 year period)

I used the Table A, Sunshine hours (Sonnenscheindauer), years 1981-2010.

The data from there can be easily converted into a CSV file by copying it in a spreadsheet software (e.g. Libreoffice) and save it as CSV.

To further process the data I used python which makes it straight forward to read CSV files and plot map data with the Basemap library. To create an evenly distributed grid of data from the not evenly distributed measurement points I use the matplotlib.mlab.griddata function and to plot the data on that grid the contourf function. The code provided in this gist (attention, in the gist the latitude and longitude are switched!) helped a lot.

My final script can be found here: https://raw.github.com/syngron/misc/master/DWD_sunshine_hours_Germany.py

The output of the script is shown in the pictures.

The first one uses a global scale which makes it nice to see the obvious changes over the seasons of whole Germany.

The second one is even more interesting, here each month has ist own scale and you can clearly see the regional differences per month. An interesting point is, that in the summer months the sunlight seems to be much more evenly distributed apart from the hole in the mid-west. In the winter month the most southern parts (the region is actually the Allgäu) seems to get much more sunshine then the whole rest. Probably this is related to the high altitudes there, the Allgäu stations are just over the clouds :)









Monday, January 14, 2013

New Google Calendar wall like column year view


The blog has moved to syngron.com


I am a happy Google Calendar user, however I was always annoyed by two things. One of those things was the missing year view which I fixed now by programming a new Google Calendar Gadget which you can find on my Github page. It creates a year view with each month in one row and all the events from your selected calendars:
https://raw.github.com/syngron/misc/master/SyngronYearView.html

Column year view with events in red (German public holidays)
To add the Gadget to your calendar just follow the link below while you are logged in to your Google account:
https://www.google.com/calendar/render?gadgeturl=https://raw.github.com/syngron/misc/master/SyngronYearView.html

The other annoying thing is not being able to smoothly scroll between months in the Google Calendar. At the end of the month I am not interested in the last four weeks before but more in the coming 4 weeks but in the online view there is only the static monthly view available at the moment. That annoyance I could not fix yet.

When I searched for a year view I found out that it was available through Google Labs as a gadget. Unfortunately I was very disappointed by it. I was expecting a typical wall calendar like we have it in German offices many times. These calendars have just 12 columns where each columns is one month. Each day of the months has a little field to the right to fill in simple informations or write the important office or holiday days. The Google Labs year view on the other hand is composed of a grid with four columns and three rows and each grid cell has the information of one month with no space for information of events. The next problem was that not even the days with events were marked specially. I know already how a year calendar looks, what I do never remember is where on that calendar I have appointments!

After googling a while I did find at least a version of this year view calendar with days with events being marked in a different color. However the event marking did not work properly when I last checked (found on the webbricks blog).

In the end I did not find any solution which resembled my view of a year view. After studying both codes, the one of the original Google Labs calendar gadget and the one from webbricks I thought however that I could try to build my own Gadget with my very rusty Javascript, HTML and CSS skills and the two templates. You can see the not quite perfect result in the picture above.

The Gadget works quite good and shows each month in one columns with all the events of the selected calendars in a separate row of the day just as I wanted it. But I was still not able to fix the height of the calendar table columns to an equal size. So months with more days or more events will be longer than others. Another issue is that if the screen is too small, months are cut off at the bottom (decreasing the font size with e.g. CTRL+MINUS can fix that). Another problem that came up with my real events was, that all events from the first five months were shown, but sometimes not all of the later months. I poll the calendar API monthwise and correctly check for events which last over the time of two different months, maybe the API does not allow too many polls in a row. I also found out that one single poll for the whole year does not work. I experimented with window lengths of days and weeks for polling but they were slower than the month wise polling and resulted in the same missing events sometimes. If somebody knows why that happens please tell me.

To sum it up I can say that the Google Calendar Gadgets are a great option and they can be programmed quite easily if you know web design a bit. The only problem is the annoying debugging procedure which involves reinstalling the Gadget after each code change so that the Google cache is not loading the cached version again. The cache is caching Gadgets for one hour and for me also the option ?nocache did not help. So it is best to pre-test Gadgets on your own server before trying them with the Google Calendar API.

Sunday, December 23, 2012

UG007 HDMI Android stick experiences


The blog has moved to syngron.com


Just to clarify, I am not liable if you destroy your device with the information given here. No guarantee given. If you follow this guide, you do it on your own responsibility and risk.

Order process

I recently ordered a UG007 HDMI Android stick on geekbuying for around 50 €. The package took around 3 weeks to arrive in Germany and was unfortunately first blocked by German customs. After paying the import tax (19%) I could finally take it home.

WIFI problems

For 50 € (+ 10 € taxes) it is an amazing piece of hardware! It worked out of the box quite good, only the WIFI made sometimes problems as mentioned by other users. To fix this, it actually helped to change the power supply. If I use as the power supply my cell phone charger or my laptop USB port the wifi works permanently. Must be some issues with too less or too much voltage with the shipped power supply.

Rooting the device

I wanted to use the stick as a media and gaming platform. So the first thing I tried was to root it, to be able to install the sixaxis software to use my Playstation 3 bluetooth controller with it.

To root the device from a Linux (Arch Linux) machine I did the following:
  1. plug the USB cable to power the stick in the Laptop
  2. check the Settings -> USB -> Connect to PC box on the stick
  3. check the Settings -> Developer options -> USB debugging box on the stick
  4. check on the Laptop the hardware ID of the stick with lsusb (the 4 digits before the colon, mine was 2207 it did not show any vendor string though).
  5. add a udev rule /etc/udev/rules.d/51-android.rules with the content SUBSYSTEM=="usb", ATTR{idVendor}=="0x2207", MODE="0666" (of course change 2207 here to your hardware id).
  6. make it executable chmod +x /etc/udev/rules.d/51-android.rules
  7. restart udev
  8. after that the device should be visible with the command adb devices (adb comes with the android sdk)
  9. Get the root files with busybox from somewhere (I used TPSarky-VonDroid-Root)
  10. Execute the following (probably some commands are redundant here):
  • adb shell mv /data/local/tmp /data/local/tmp.bak
  • adb shell ln -s /data /data/local/tmp
  • adb reboot
  • adb shell rm /data/local.prop > nul
  • adb reboot
  • adb shell id
  • adb remount
  • adb push su /system/bin/su
  • adb shell chown root.shell /system/bin/su
  • adb shell chmod 6755 /system/bin/su
  • adb push busybox /system/bin/busybox
  • adb shell chown root.shell /system/bin/busybox
  • adb shell chmod 0755 /system/bin/busybox
  • adb shell chown root.root /system/app/SuperSU.apk
  • adb shell chmod 0644 /system/app/SuperSU.apk
  • adb push RootExplorer.apk /system/app/RootExplorer.apk
  • adb shell chown root.root /system/app/RootExplorer.apk
  • adb shell chmod 0644 /system/app/RootExplorer.apk
  • adb shell rm /data/local.prop
  • adb shell rm /data/local/tmp
  • adb shell mv /data/local/tmp.bak /data/local/tmp
  • adb reboot
And that's it. The stick is rooted now.

Sixaxis PS3 controller over bluetooth

After that I installed the sixaxis app on the stick. The trick here is to change the master adress of the controller to the one of the stick. When running the sixaxis app, the bluetooth adress of the stick should be shown at the bottom. On my Linux laptop I used the controller before with the qtsixa application which is available in the AUR. This package also ships an application called sixpair which takes as an argument a bluetooth hardware adress. So after connecting the controller to my Linux box with USB and changing the hardware adress with sixpair it was working on the Android stick.
Btw for Linux I can recommend also the application qjoypad which allows to remap all the keys of the controller to keyboard events. It is possible e.g. to map the motion sensors to mouse movements. Otherwise there is also the package xf86-input-joystick available in the extra repository which allows X11 controls with the controller.

Flashing Linux

This was already nice but I was not completely satisfied with the Android system, I am used to use bash or python scripts extensively to automate tasks which was not so easy on the Android system. Furthermore the behaviour of Android with a connected mouse and keyboard still feels not right. You always have to think in touch screen ways. So I wanted to flash Linux on the stick.

Luckily there is this guy AndrewDB on the slatedroid forums which created a Linux image for the Rockchip based Android sticks (thanks for that!):
http://www.slatedroid.com/topic/41654-pre-alpha-03-ubuntu-linux-for-mk802-iii-ug802-mk808-ug007-imito-mx1/

The only problem is that all the tutorials are based on flashing the device from a Windows box. Flashing Linux on an Android stick from Windows, why not use also Linux in the first place?

The flashing works basically by setting the stick to a flashing mode and overwriting the recovery partition which is /dev/block/mtdblock3 on the stick. In the slatedroid forum thread a guy named Patola had success by just using cat to overwrite the recovery partition with the zero padded kernel image (the partition has 16 mb the kernel image is around 8 mb).

I tried several things:
  • Padding the kernel image with zeros:  dd if=/dev/zero bs=1 count=8536064 >> kernel-0.3_pad.img (8536064 is the difference in byte between 16 mb and the kernel image size)
  • Then overwriting the partition with dd: dd if=kernel.img of=/dev/block/mtdblock3 bs=8192 (I also tried different block sizes)
  • Overwriting it with cat: cat kernel.img > /dev/block/mtdblock3
  • First overwriting the partition with zeros: dd if=/dev/zero of=/dev/block/mtdblock3 bs=8192 and then doing the above
Unfortunately all of the above methods did not properly overwrite the partition, each time the compare command cmp yielded a different byte in the partition and the image used. A restart of the stick into recovery mode (reboot recovery) which should boot the recovery partition just brought up a blank screen. Maybe I would need to set the stick into flashing mode first somehow (reboot bootloader) but I thought of this only afterwards.

So in the end I had to try it with the Windows flashing tool RKAndroidTools. With wine it didn't recognise the stick, so I tried it with virtualbox. Here I had to first setup properly the USB device which needs the virtualbox-ext-oracle package available from AUR. With this package I was able to see the stick in the Windows XP virtual machine (after activating USB 2.0 support in the virtual machine settings). I was then able to flash the recovery image with the RKAndroidTools as described in the README. The flashing tool is available from the custom Finless Android image which is available on the freaktab forums. I basically followed the readme included but in the tool only checked the recovery checkbox to not overwrite my Android image too. Before flashing I exchanged the recovery.img of the tool with my linux kernel image. Btw if you do let the other checkboxes checked, it should install the Finless Android image which is already rooted, so the process of rooting described above is not necessary anymore (however I did not test this).

After creating a Ubuntu memory card as described in the forum thread by formatting it with gparted to ext4 and label it linuxroot I can now boot into Ubuntu by executing reboot recovery on the stick. :)

Btw the Ubuntu image from AndrewDB needs a 4 GB stick, I only had a 2 GB one around so I deleted the folders /var/cache /usr/share/help /usr/share/doc and all locales but the english ones from /usr/share/locale/. This brought the image down to less than 2 GB while keeping all the functionality I needed.