My blog, imported from Blogger and converted using Jekyll.

Bilingual interface to Cornish Corpus Statistics Python GUI application and switching between Kemmyn and manuscript spelling

May 6, 2017

As part of my taklow-kernewek tools, I created an application that can do some corpus statistics on Cornish texts, and is configurable at run-time to a certain extent.

I have made a few improvements to the files and, which include a bilingual interface, and ability to switch between using Kernewek Kemmyn and manuscript spelling (or at least a reading of such).

To create a switchable bilingual interface, I overhauled the GUI code to make it more object orientated, and created a set of dictionaries where the keys each refer to another dictionary with 2 elements {'en': 'English text', 'kw': 'Cornish text'}.

A button in the GUI then runs a function that changes the interface language, and alters the text in all of the relevant widgets to use that in the new language.

It can also be specified when running, at the command line as the -e switch which will launch with English interface.

English interface. The button at the lower left allows switching betweeen the two.

Cornish interface
I have also fixed a bug that happened when there were no words longer than the specified number of letters, and the list of word frequencies is generated. Internally, what happens inside is that the length of the longest word is found, so that the output text is spaced appropriately. Now it checks whether there is an empty list of tuples of (word, frequency) to avoid an indexing error.

The other thing I have done is fix a bug when the manuscript spelling was selected (previously only via command line -m switch, but now also in the GUI, as below). There is a different list of texts available in manuscript vs. Kemmyn, which had previously caused the program to have an index error in some cases.

Unfortunately I still have an issue with TkInter, since when switching between Kemmyn <--> manuscript there is an extra empty space generated, which needs a bit of adjustment to how the widgets pack etc. I got a bit confused when trying to fix it so am leaving it in for now.
Kemmyn (top left) and manuscript (bottom right). These windows have been launched direct from the command line, with the manuscript one launched by " -m" to choose the manuscript spelling texts rather than Kemmyn.

Annoying issue with space at the left appearing after switching within the GUI to manuscript spelling.

Update 07/05/17 - Tkinter bug fixed

After spending a while looking at my copy of Programming Python I found the pack_forget() method, which I used to remove the buttons at the lower left (language and manuscript mode switch) while the text choice list is repopulated with new radio buttons, and then the buttons are repacked afterwards.
I also show in the heading above the list texts which mode the program is in.

In Kemmyn mode, showing the most frequent words of at least 5 letters in Passyon agan Arloedh

In manuscript spelling

Mathematics quiz in Cornish with some improvements

May 4, 2017

I have made some improvements to the mathematics quiz in my taklow-kernewek tools.

There is now a facility to set a difficulty level, either easy where numbers are always 1-10 and negative answers are suppressed, medium allowing numbers up to 20 and hard allowing numbers up to 40.
The program asks what 10 + 32 is, the answer of course is 42.

The user has answered the question 19 - 33 incorrectly as -4. The program has repeated the previous question in text and figures along with its answer.

The report at the end shows how many questions were answered correctly, and what the points score was. I may well revise the way this calculated since at present it can reward speed more than accuracy (1 point is given for each correct answer and 10-t for speed where t is the number of seconds taken to answer, up to 10 seconds).

Mathematics Quiz in Cornish

May 3, 2017

One of the things I discussed in my talk last year at the Skians conference as possible future developments in software for Cornish is tools or games for learners.

In a first step in that direction, I have programmed a mathematics quiz which asks twenty questions of addition or subtraction, in a Python Tkinter GUI app (or at the command line), to help users practice recognising Cornish numbers.

After entering a number in the box, click on "Profya Gorthyp" or press Enter to submit the answer.

The computer checks the answer for correctness, then shows the time taken for you to submit it, number correct out of questions answered so far, and the total points. One point is awarded for a correct answer, and extra points for speed.

After 16 questions answered, 14 were correctly answered, and total points is 75.4

The end of the quiz after 20 questions.
The code is at my taklow-kernewek repository at Bitbucket. I will likely add a little more to it, including perhaps some different difficulty levels, and maybe some multiplication or division at some point.

Some nice clear satellite images of Cornwall with Landsat 8 and Sentinel 2

Apr 29, 2017

The launch of Sentinel 2A and 2B as part of the European Space Agency's Copernicus Program, has increased the frequency with which medium resolution satellite imagery in optical and near infrared is available.

Landsat 8 (and 7) are also still operating, which take a given frame every 16 days each.

Landsat 7 unfortunately has a scan line corrector fault that means there are stripes of missing data:

There was a particularly cloud free image of Cornwall on Landsat 8 on 27th March 2017, which I show below, displayed using tuiview.

On the left is a visible light band combination using bands 2, 3 and 4 which are broadband blue, green and red bands, and on the right I use band 7 (which is known as SWIR2, which stands for short-wave infrared 2, at around 2.2 micrometres wavelength), band 5 (near infrared), and band 4 (red, but shown as blue here). Infrared bands can be a bit confusing, especially if you have been exposed to both terrestrial remote sensing and astronomers terminology.

A somewhat closer view, with Truro at the top-right, showing Falmouth, the Fal estuary, Camborne and Redruth, and Stithians Reservoir in the centre.
Sentinel 2 has also captured some good clear images recently in the area, such as this. These are processed in the Sentinel 2 Toolbox within the Sentinel Application Platform, using sen2cor to process to Level 2A (surface reflectance)

This is from 18th April 2017, with a clear view of parts of Cornwall.
Sentinel 2 also took a mostly clear (apart from some high cloud) image on 27th March 2017:

The top image uses bands 2, 3 and 4 for the blue, green and red channels respectively, and the bottom uses 2, 8 (842nm) and 12 (2190nm).
Since the different bands are at different resolutions, when using the Sentinel Application Platform it is necessary to resample the output under the Raster menu, to process it further. This can produce a very large file, so I used the GeoTIFF / BigTIFF option because otherwise it would produce a file larger than a standard GeoTIFF file can be, when the 10m resolution is used. This can then be converted to a .KEA file for a smaller file size with gdal_translate.

The reason the file size is enormous is the output from resampling has 45 bands, because although it outputs only 10 data bands, that is 2, 3, 4, 5, 6,7 ,8 , 8a, 11 and 12, there are also atmosphere optical depth, water vapour, cloud probability, snow probability, and a scene classification, and then bands describing zenith angle, solar angle for every bands. As an uncompressed GeoTIFF this was 22 gigabytes for each tile, but is less than 1GB as a KEA (and I selected only the first 15 bands using rsgislib).
Four Sentinel 2 tiles combined (UUA, UUB, UVA, and UVB) to provide an overview of Cornwall and Devon - with border overplotted in QGIS - visible light

Using Band 12 = red, Band 8 = green and Band 2 = blue.
I have also opened them in QGIS and overplotted a map based on OpenStreetMap:

Sentinel 2 - 18th April 2017 - visible light
Sentinel 2 - 18th April 2017 - Band 12 (2.2 μm), Band 8 (842nm), and Band 2 (blue).
Landsat 8 - 27th March 2017 - Bands 4 3 and 2 (visible light)
Landsat 8 - 27th March 2017 - Bands 7, 5 and 2

Sentinel 2 - 26th March 2017 - visible light

Sentinel 2 - 26th March 2017 - Bands 12, 8, 2

Another possible band combination of the 18th April image, which is visible light but with the red and green channels swapped, and blue stretched a bit further to attempt to see the bluebells in the woodland shown from Sentinel2. The location is just to the right of the gridlines crossing at 183000, 41000

I will blog again about some of these when I have some time to experiment with processing. I have used the Sentinel 2 Toolbox and sen2cor to process the images, but I would also like to try ARCSI for processing from Level 1C to surface reflectance for Sentinel 2.

Cornwall to divide from Devon with new reservoirs

Apr 1, 2017

The Duke of Cornwall has published plans today, 1st April 2017, Dy' Kalann Ebrel, for a series of dams in the Tamar Valley. This will have a number of benefits:
  • The three reservoirs will generate hydroelectric power. They will be linked by a pumped storage system so that they can store energy generated by wind and solar farms in the area when they generate in excess of demand and allow water through the turbines generating electricity when it is needed.
  • The project will allow a new not for profit water company Dowr Kernow which will provide competition for South West Water and drive down prices for customers.
  • The new reservoirs will better define the border between Cornwall and England, which it is hoped will prevent a cross-border "Devonwall" constituency from being implemented. 
The Duke of Cornwall will be able to use feudal prerogatives to require Cornwall Council to accept the plans.

Although the required compulsory purchase of the land and buildings will be extensive, the Duke points out he does own quite a bit of it already, and has offered to give an (as yet unconfirmed) discount on new properties in the Duchy's housing development to his subjects who are affected by compulsory purchase.

    The Cornwall-England border, showing the three proposed new reservoirs along the Tamar Valley
    A closer view of the area, with some detail of the proposals.

    Lyn Tredamar, the northernmost of the three reservoirs, with a dam near Boyton (Trevoya) giving a water level of 100m. The border will be restored to the 936 treaty border between King Athelstan of England and King Hywel of Cornwall, which will see West Bridgerule restored to Cornwall, and the part of North Tamerton east of the Tamar will revert to Devon.

    The central, and largest of the lakes, Lyn Lannstevan, with a dam at Greystone Bridge and a water level of 70m. There will be a need for a new bridge to carry the A30 over the reservoir, which will also carry a cantilevered cycle track, which will connect to minor roads near Broadwoodwidger enabling bypassing of the flooded section of the road through Lifton and Tinhay.

    The southernmost lake, Lyn Dowrgonna, with a dam at the location of Gunnislake bridge giving a water level of 50m. The Tamar Valley Area of Outstanding Natural Beauty is shaded in yellow, and the Cornish Mining World Heritage Site in grey. Some of the historic ruined buildings which are part of the World Heritage Site will need to be moved to higher ground. Doing this in a UNESCO World Heritage Site will be controversial, but it is hoped that the planned moving of Stonehenge to make way for the new A303 dual carriageway will set a precedent which will help acceptance of this action.

    The more radical proposal of creating a single 100m level reservoir with a dam at Greystone Bridge. This plan is thought to be unrealistic given the likelyhood of legal action from Devon County Council due to the quantity of land and buildings flooded.

    Reservoir Total area (km^2) Average depth (m) Volume (million m^3)
    Dowrgonna (50m) 7.09 16.41 116.3
    Lannstevan (70m) 16.96 11.51 195.2
    Tredamar (100m) 14.09 9.3 131.0
    Lannstevan (100m) 83.06 18.5 1538.39

    The above table shows the area and volume of the proposed reservoirs.

    To store energy from renewable generation, a cubic metre of water can thus be raised 50m from Dowrgonna to Lyn Tredamar, which means it gains 1000*9.8*50 J of potential energy, or 20m from Dowrgonna to Lannstevan.

    If the upper two reservoirs were emptied there could be 17.8 million kilowatt hours stored by raising water to Lyn Tredamar, and a further 10.6 million kWh by raising water to Lyn Lannstevan.

    There are approximately 1100 properties expected to be below the waterline, which would rise to about 3600 if the 100m water level option was followed for Lyn Lannstevan. However, it was pointed out that this option would lead to the submerging of Prince Charles Close in Launceston, so therefore the Duke doesn't favour this option.
     Critics of the project have questioned whether this project fits in with Prince Charles' environmental campaigning however the energy storage system will support the development of renewable energy and reduce reliance on fossil fuels.

    The cost of the project is unknown, however Prince Charles has assured his subjects, that it will be cheaper than Trident replacement, and less environmentally destructive than a nuclear war.

    All Posts