On Readable Python Code

Standard

Python is an very nice high-level programming language that provides the user with an easy way to write readable and clean code. It is often the case when someone is learning a new tool or language that they are not aware of small features that would greatly improve the readability of their code.

For example, when I was learning Python I learned to iterate over a list the way I keep seeing it when reading code of beginner Pythonists. Here is an example of how you could iterate over the list:

for ix in range(len(a_list)):
    print(a_list[ix])

However, a better and Pythonic way is to use iterators:

for el in a_list:
    print(el)

This equally works for dictionaries and strings:

for key in a_dictionary:
    print(key)

for char in a_string:
    print(char)

Convolutional Neural Network for Oil Spill detection in Synthetic Aperture Radar Satellite Images

Image

Python

Link

Intermediate and Advanced Software Carpentry

Problem Solving with Algorithms and Data Structures using Python

 

Anaconda Python needs cleaning every once in a while

Standard

As a user of Anaconda python I have been receiving (Ubuntu) system warnings of low free space in my home directory. Investigating what was causing this I found out that Anaconda python had several versions of each package. The overall size of the pkgs directory was 14+ GB. After cleaning it is about 3GB.

The second largest directory was my mail in Thunderbird.

So it would be wise, especially if you are limited in disk space, to clean Anaconda. The commands I used are as follows:

 
conda clean --all
conda update conda
# just to make sure nothing is broken and
# your environment is updated
source activate <your-environment>
conda update --all
conda clean --all

Global SRTM Map

Image

global_srtm_bathymetry_map

The following is an 20x downsampled global Shuttle Radar Topography Mission (SRTM)  map made with Python and Basemap.

Full resolution can be found on wikimedia.

One can notice the depth of the ocean floor, on a global scale, ranges between -2000 and -6000 meters. In some regions though like the Pacific exceed this range and reach 11 kilometers below the sea surface. One such region is the deepest point on Earth, the Mariana trench as shown below followed by a map for a perspective of its location.

368px-marianatrenchmap

Location of the Mariana trench. Wikimedia commons.

Credits: The SRTM dataset used was provided by IFREMER.