Tuesday, October 10, 2023

Dive into Python: Essential Tutorial Series for Ocean and Climate Researchers

 


Target Audience:

  • Bachelors students/ Masters Students/ Ph.D students
  • Researchers involved in coastal upwelling, mesoscale eddies, climate future projections (CMIP5, CMIP6), Physical-Biogeochemical modelling

Getting Started with Python: Installation Guide for Windows and Linux

Python is a powerful, versatile, and beginner-friendly programming language that has gained immense popularity over the years. Whether you're looking to dive into data science, web development, or automation, Python is a great choice. In this guide, we will walk you through the process of installing Python and Jupyter Lab on both Windows and Linux operating systems, so you can start your Python journey.

Prerequisite: Internet connection and Windows 8 or earlier

Windows

Let's install Python3 on Windows

STEP 1. Visit the Python Website:

   - Go to the official Python website at https://www.python.org/.

   - Click on the "Downloads" tab.

STEP 2. Download Python3 Installer:

   - Scroll down to find the latest version of Python3 for Windows.

   - Choose the installer that matches your system (usually a 64-bit version is preferred).

   - Click on the download link to start the download.

STEP 3. Run the Installer:

   - Once the installer is downloaded, double-click on the executable file (.exe).

   - Check the box that says "Install launcher for all users”

   - Check the box that says "Add Python x.x to PATH" during the installation.

   - Click Install Now to complete the normal installation.

STEP 4. Verify the Installation:

   - Press Windows key + r and type cmd and click OK OR Go to start and enter cmd

   - A command prompt will open and type:

python --version

OR

python -V

You should see your default Python version.

But, Sometimes, you won't be able to see your python3 version, in that case you need to type the following command to verify your python3 version:

python3 --version
Lets install Jupyter Lab on Windows

STEP 1. Install Jupyter Lab:

   - Open a command prompt or terminal.

   - Type the following command and press Enter:

pip install jupyterlab

STEP 2. Launch Jupyter Lab:

   - In the command prompt or terminal enter.

jupyter lab

   - Jupyter Lab will open in your default web browser.

Linux

Lets install Python on Linux
Most Linux distributions come with Python pre-installed. To check if it's already installed, open a terminal and type:
python --version

OR

python -V
If Python is not installed or you want to install a specific version, follow these steps:

STEP 1. Open Terminal:

   - Open a terminal on your Linux distribution.

STEP 2. Install Python:

   - Use the package manager specific to your distribution (e.g., apt for Ubuntu, dnf for Fedora, or pacman for Arch Linux) to install Python. For example:

     - Ubuntu/Debian:

sudo apt-get install python3

     - Fedora:

sudo dnf install python3

STEP 3. Verify the Installation:

python --version

OR

python -V

   - Type `python --version` to verify the Python installation.

Lets install Jupyter Lab on Linux

STEP 1. Open Terminal:

   - Open a terminal on your Linux distribution.

STEP 2. Install Jupyter Lab:

   - Use the package manager to install Jupyter Lab. For example:

     - Ubuntu/Debian:

sudo apt-get install jupyter

     - Fedora:

sudo dnf install jupyter-notebook

STEP 3. Launch Jupyter Lab:

   - In the terminal enter.

jupyter lab

   - Jupyter Lab will open in your default web browser.

Conclusion

With Python and Jupyter Lab successfully installed on your Windows or Linux system, you are ready to explore the world of Python programming and data analysis. Now you can start coding, creating projects, and taking advantage of the vast ecosystem of Python libraries.

Cheers!

Happy coding!

Subscribe, share and comment.

Stay tuned for more classes.

Sunday, August 13, 2023

Kick start your R journey Getting started with R

 

Getting started with R

I hope you install the R and Rstudio successfully in your PC. 

  • Data manipulation in R is different from contemporary softwares for statistical – graphical analysis. 
  • Be in mind that R is not a software, rather it is a numerical computation program like MatLab or Octave. 

Let’s start with data( mtcars), which is usually an inbuilt dataset

R can read most of the datasets which are commonly used. Here I am going to explain how you could import a spreadsheet to R’s global environment. 

R has introduced specific options for importing spreadsheets of common formats. You could easily scroll the dropdown menu of button in title bar “import dataset”. By clicking on this you can get the options on extra plugins to download. I am going to tell a different method, ie,by using code. Most R users like this, because of its convenience in automations. In this one is an inbuilt function and another one  you have to download. Both are essential for exploring the R world .

car<- mtcars 
View(mtcars)

Browsing through columns 

dollar method

Dollar method

Browse through your columns by adding $ symbol

Square bracket and number/name method

Other methods are by using [ ] square brackets, or by using the exact column names(if you know) or by tab <=> button.

data[rows,columns]

so here it is

car[,]

You could select desired columns by using “tab” button, when the cursor is in the square bracket[ ]. Similarly, you can shift the cursor left to the coma for rows.

Find columns using Square bracket and number/name method
Find rows using Square bracket and number/name method

you can use numbers instead of names of columns. i e, for the first column use 1 and for the second column use 2.

car[,1] # For first column
car[2,]# For second column

Get first four columns from the data[car], you have to select multiple columns by using the command “c”.

car[,c(1,2,3,4)] # first four columns by using no.s.
car[,c("mpg","cyl","disp","hp")] #first four columns by using names.

In the same way you can use rows too. Lets check the first 4 rows.

car[c(1,2,3,4),] # first four rows by number
car[c("Mazda RX4","Mazda RX4 Wag","Datsun 710","Hornet 4 Drive"),]#first four rows by name

Everything in the R needs a name, as in real life scenario. Otherwise R will forgot, and won’t seen on global environment.

 carpart<-  car[,c(1,2,3,4)]

This way you can define the subsets, i e you made your own dataset from the previous one.

Point data manipulation

You can do point data editing in R, before you doing this you should have a better understanding on datasets you are dealing with. For this you have to  specify both rows and columns.

just type

car[3,3] # 3rd row and 3rd column

check the output

[1] 108

Suppose you could change the value from 108 to 50

car[3,3]<- 50

Change row names and column names

Row names can be changed by function rownames(), lets the check the subset data “carpart” with rownames.

rownames(carpart)
[1] "Mazda RX4"           "Mazda RX4 Wag"       "Datsun 710"          "Hornet 4 Drive"      "Hornet Sportabout" 
[6] "Valiant"             "Duster 360"          "Merc 240D"           "Merc 230"            "Merc 280"          
[11] "Merc 280C"           "Merc 450SE"          "Merc 450SL"          "Merc 450SLC"         "Cadillac Fleetwood"
[16] "Lincoln Continental" "Chrysler Imperial"   "Fiat 128"            "Honda Civic"         "Toyota Corolla"    
[21] "Toyota Corona"       "Dodge Challenger"    "AMC Javelin"         "Camaro Z28"          "Pontiac Firebird"  
[26] "Fiat X1-9"           "Porsche 914-2"       "Lotus Europa"        "Ford Pantera L"      "Ferrari Dino"      
[31] "Maserati Bora"       "Volvo 142E"

If you want to know column names, you can use two commands

colnames(carpart) # colnames is a specific function
[1] "mpg"  "cyl"  "disp" "hp" 
names(carpart)# names only work work for dataframes
[1] "mpg"  "cyl"  "disp" "hp"

You can change the column names/row names by assign the new names in order, lets check the column names.

names(carpart)
[1] "mpg" "cyl" "disp" "hp"

Now assign with new name

names(carpart)<- c("miles/gal","cylinder","displacement","horsepower")
# or
colnames(carpart)<- c("miles/gal","cylinder","displacement","horsepower")

In conclusion, the first class of an R programming journey is a foundational step towards mastering this versatile and powerful language. As you delve into R, you'll find yourself equipped with the essential knowledge of its syntax, data structures, and basic programming concepts. This initial exposure sets the stage for more advanced topics like data manipulation, visualization, and statistical analysis, which are at the heart of R's capabilities. Whether you're a data scientist, statistician, or just someone interested in data-driven insights, the skills you acquire in this first class will serve as the building blocks for your future exploration and expertise in the world of R programming. So, embrace this beginning with enthusiasm, for it opens the door to a realm of endless possibilities in data analysis and beyond. 

Sunday, August 6, 2023

One Ocean Expedition - A Voyage of Learning and Adventure


The Nansen Environmental and Remote Sensing Center (NERSC) and the European Space Agency (ESA) collaborated to organize a unique ocean synergy training course known as the One Ocean Expedition. This expedition was a part of the Partnership for Education and Cooperation in Operational Oceanography (PECO2) project, aimed at supporting marine services tailored to the environmental and climate change needs of the southern African oceans. The expedition took place aboard the historic Norwegian sailing ship, Statsraad Lehmkuhl, during its journey from Maputo, Mozambique, to Cape Town, South Africa, from 3-13 January 2023. We, two fortunate participants from India, were lucky to be part of this extraordinary journey.

Embarking on an Extraordinary Journey:

One of the Indian Participant Dr. Sreelakshmi Sreenivasan during her Helm watch

Our adventure began on 31st December, as we set out from Kochi to New Delhi and then to Ethiopia to celebrate the New Year. From Ethiopia, we traveled to Maputo, Mozambique, where we met Mr. Franck Ghomsi, another participant of the expedition. The excitement and exhaustion were palpable as we reached the beautiful city of Maputo. Before commencing the expedition, we refreshed ourselves at the Maputo Waterfront, where we had the pleasure of meeting most of our co-participants. Little did we know that this voyage would lead us to encounter the majestic "Statsraad Lehmkuhl."

The Historic Sailing Ship "Statsraad Lehmkuhl":
Statsraad Lehmkuhl is a square-rigged ship with a rich history dating back to 1914 when it served as a training ship for the German merchant fleet. For over a century, this remarkable vessel has sailed under the Norwegian flag and is recognized as one of the largest, oldest, and most beautiful ships of its kind worldwide. Despite its age of 108 years, the ship remains in excellent condition, having recently completed its first-ever circumnavigation as part of the One Ocean Expedition. With its 22 sails, it can reach a speed of 17 knots, while its diesel engine propels it at 11 knots. Equipped with a desalination plant using reverse osmosis technology, the ship ensures a constant supply of freshwater while at sea. Various instruments on board allowed us to collect critical data, enabling us to monitor essential upper ocean features and their connection to satellite data.

A Diverse Group of Participants:
The training course was an invaluable opportunity for ocean enthusiasts. Thanks to the sponsorship of the European Space Agency, 20 students from their member states, including 40 students and Post Docs from the PECO2 project, participated. Among them were individuals from diverse backgrounds, including high school students, teachers, researchers, scientists, police officers, doctors, and entrepreneurs from 30+ nationalities.

Embrace both fashion and function, ensuring you stay dry and stylish throughout the expedition

Elevate your cruise experience with our exquisite collection of Raincoats, designed to make a statement on the high seas.

This collaboration fostered an atmosphere of learning, collaboration, and friendship throughout the journey. Our voyage took us along the Agulhas Current, one of the world's most powerful ocean currents, flowing southward from Madagascar along the African coast. The collision of cold Atlantic waters and warm Indian Ocean waters near the southern tip of Africa results in upwelling nutrient-rich water, creating a vibrant marine ecosystem. This region's significance for scientific exploration made our expedition even more exciting.

Research and Activities Onboard:
On January 2nd, we embarked on our journey from Maputo Port, forming three research groups: Air-Sea Interaction, Ocean Dynamics, and Marine Biology. Each group further split into subgroups, allowing participants to explore their specific interests. At various stops along the way, we collected ocean data, including temperature, salinity, density, plankton, and other chemical conditions. The ship's crew and scientists assisted us in gathering valuable information about the Agulhas current's strength and the region's climate.

https://www.youtube.com/watch?v=aGlEC6fWtVM&list=PLV4pEzhVpJXqPdEnY2lBQtOpO26TbFDy-&index=1&pp=iAQB
A nice evening with a flavour of music
https://www.youtube.com/watch?v=y1twQjY4F2A&list=PLV4pEzhVpJXqPdEnY2lBQtOpO26TbFDy-&index=3&pp=iAQB
A rope knot competition
https://www.youtube.com/watch?v=rsp9dsEAVfw&list=PLV4pEzhVpJXqPdEnY2lBQtOpO26TbFDy-&index=4&pp=iAQB
Deck cleaning activities
https://www.youtube.com/watch?v=BnNnOSoJyko&list=PLV4pEzhVpJXqPdEnY2lBQtOpO26TbFDy-&index=5&pp=iAQB
Another day evening, another music vibe
https://www.youtube.com/watch?v=7ikJDJVt7Fs&list=PLV4pEzhVpJXqPdEnY2lBQtOpO26TbFDy-&index=6&pp=iAQB
Making fast. Så smått.. Haul taut.. come up.
https://www.youtube.com/watch?v=-ojG4cveBGE&list=PLV4pEzhVpJXqPdEnY2lBQtOpO26TbFDy-&index=7&pp=iAQB
Not so fun as it looks.. Ha ha
https://youtu.be/6_AJ9WaEeAA
Sail job on a windy day

An Unforgettable Experience:
Apart from research, the voyage was filled with numerous activities to keep spirits high. We were involved in watches such as Bouy, Look out, Fire, Helm, Science watches, each with specific duties and responsibilities. We had the privilege of climbing masts, setting sails, and steering the ship, which felt like being the captain of a pirate ship in the high seas. Amidst these exhilarating moments, we even encountered the stormy nature of the Agulhas current, an experience that tested our mettle and taught us valuable lessons about the sea. The One Ocean Expedition was indeed an adventure of a lifetime. We formed lasting bonds with fellow participants from around the world and shared moments of both excitement and challenges. The journey on Statsraad Lehmkuhl provided us with a unique platform for learning, research, and personal growth. We are grateful for this incredible opportunity and will forever cherish the memories of our time at sea. As we disembarked in Cape Town, South Africa, we knew that this voyage had expanded our horizons, both literally and metaphorically, and instilled in us a deep appreciation for the beauty and fragility of our oceans. The One Ocean Expedition will remain etched in our hearts as a voyage that united us in the pursuit of knowledge and a shared love for our planet's vast blue expanse.

Those are not birds hanging out in the mast, but us sailors setting sails

Written by Akash & Ullas

Meet Akash S, a passionate early career scientist, has 5 years of research experience in Climate Variability, Ocean Dynamics, Fisheries Oceanography, and Ocean Modeling, specializing in Climate Change Adaptation. He holds a Master's from the prestigious College of Climate Change and Environmental Science, KAU, Thrissur, India, and his programming skills in FERRET, Python, Shell, R, and FORTRAN empower him to manage extensive datasets. Nowadays, he is more focused on investigating the Coastal and Open Ocean Deoxygenation and fisheries using in-situ datasets and physical-biogeochemical models by pursuing his Ph.D. in Physical Oceanography at KUFOS & Nansen Environmental Research Centre (India), Kochi, India. His love for the Ocean knows no bounds, driven by an unwavering commitment to sustainability, Akash actively participates in scientific cruises, adeptly collecting data with sophisticated instruments, safeguarding marine ecosystems for the future. Join his captivating journey of ocean exploration, scientific innovation, and programming prowess.


"I am a researcher at the Nansen Environmental Research Centre in India. I am passionate about ocean research, and my research interests include ocean dynamics and sea level changes and I am being awarded the prestigious NANSI Ph.D fellowship from the Nansen Scientific Society in Norway. My passion for ocean research began when I was a child, as I was fascinated by both the sky and the ocean. But I realized that I was more drawn to the ocean and I decided to pursue a career in oceanography so that I could explore the ocean's mysteries which is not yet known to full. My master's curriculum in physical oceanography introduced me to wider topics and provided me with a strong footing in the field of ocean sciences. I am excited to continue my research and contribute to our understanding of the ocean."

Friday, July 21, 2023

The Fascinating World of Jellyfish, A joy of Sampling

 Let me say something about a beautiful organism - the Jellyfish. A creature both fascinating and enigmatic, the Jellyfish is a curious, sometimes dangerous, boneless, brainless, heartless, eyeless, earless, noseless, tongue-less marine wonder that has thrived on Earth for hundreds of millions of years. Despite lacking many of the characteristics that define us as humans, Jellyfish remain an integral part of marine ecosystems, distributed worldwide. Join me on this journey as we explore the captivating world of Jellyfish from a researcher perspective.

Size and Diversity of the Resilient Survivors:

Water comprises more than 90 percent of the Jellyfish's body mass, making them exquisitely adapted to aquatic life. Their ability to survive even in low-oxygen conditions showcases their remarkable resilience. It is awe-inspiring to think that these creatures have persisted through countless millennia, witnessing the rise and fall of various species. Jellyfish exhibit an astounding size range, from millimeters to meters, showcasing remarkable species diversity. The diversity within the species is truly astounding. Each Jellyfish species holds its own unique beauty, adding to the wonder of marine biodiversity. This diversity necessitates caution and knowledge when dealing with them.

Challenges in Study and Collection:

The weird habituation of jelly fish with plastic pollution

Studying and collecting Jellyfish can be a little complicated compared to working with fish. In estuarine conditions, researchers often use scoop nets to gather Scyphozoan Jellyfish for research purposes. However, handling these delicate creatures requires explicit knowledge of their stinging property to avoid complications and health problems. Their delicate, undulating forms and vibrant colors make them a captivating sight. However, caution must be exercised, as some Jellyfish species are highly toxic and dangerous to humans. Wearing gloves while collecting unknown Jellyfish from the wild is essential to prevent accidental stings.Wearing gloves while collecting unknown Jellyfish from the wild is essential to prevent accidental stings.

Observations in the Estuary: Jellyfish in Kerala 

In Kerala, Jellyfish are commonly known as 'kadalchori', a term that directly refers to the itching sensation they can cause in humans. While Kerala is rich in marine resources, the culture, capture, and trade of Jellyfish are not as common as one might expect, despite their abundance. Kerala remains unexplored in terms of tapping into the potential export market for these fascinating creatures.In the estuary, Jellyfish often come close to the shore, making it relatively easy to collect them using scoop nets. 


They exhibit a slow swimming behavior, allowing for close observation. However, in deeper waters, the collection process becomes more complex as they swiftly retreat when sensing danger nearby.

Examining, Photographing, and Preserving:

After collection, the Jellyfish samples are meticulously examined, photographed, and preserved, with only a limited number of samples being designated as museum specimens in buffered formalin solution. Such measures ensure that their beauty and scientific value are preserved for generations to come.The world of Jellyfish is a captivating and mysterious one, full of astonishing diversity and survival stories. From their resilience in adverse conditions to their stunning beauty, there is much to appreciate and learn from these ancient marine organisms. While they can pose challenges and potential dangers, with proper safety measures and knowledge, we can interact with them responsibly, opening doors for further research and exploration of their fascinating world. As we continue to explore and understand Jellyfish, let us remember the importance of safeguarding our marine ecosystems and the wondrous creatures there inhabited.

I am a researcher in Jelly fishes, currently doing PhD at Cochin University of Science and Technology. My core interests are in marine ecology, scientific illustrations, light microscopy and Aquaculture. I am very much interests in field surveys, particularly on plankton samples. My current work is focused on distribution of jelly fishes over the Cochin estuary.

— Rithin Raj, CUSAT

Tuesday, January 10, 2023

Getting started with R

I hope you install the R and Rstudio successfully in your PC. Data manipulation in R is different from contemporary softwares for statistical - graphical analysis. Be in mind that R is not a software, rather it is a numerical computation program like MatLab or Octave. A detailed review on the capabilities of R were explained the post. Here we are going to start with basic data manipulation on R for extreme beginners. Let's start with

data( mtcars), which is usually an inbuilt dataset. To make you know how to import a data from your PC, just go to the link here.car<- mtcars
View(mtcars)


Browsing through columns
1) Dollar method

Browse through your columns by adding $ symbolcar$





2) Square bracket and number/name method

Other methods are by using [] square brackets, or by using the exact column names(if you know) or by tab <=> button. However the result will be the same. Like maths, in R you can solve the same problems in different ways. Use the codes according to your convenience, and your data structure. Inside the [] , the data is represented by rows and columns.The basic structure isdata[rows,columns]


so here it iscar[,]


You could select desired columns by using "tab" button, when the cursor is in the square bracket[ ]. Similarly, you can shift the cursor left to the coma for rows.







you can use numbers instead of names of columns. i e, for the first column use 1 and for the second column use 2.car[,1] # For first column
car[2,]# For second column


Get first four columns from the data[car], you have to select multiple columns by using the command "c".car[,c(1,2,3,4)] # first four columns by using no.s.
car[,c("mpg","cyl","disp","hp")] #first four columns by using names.


In the same way you can use rows too. Lets check the first 4 rows.car[c(1,2,3,4),] # first four rows by number
car[c("Mazda RX4","Mazda RX4 Wag","Datsun 710","Hornet 4 Drive"),]#first four rows by name


Everything in the R needs a name, as in real life scenario. Otherwise R will forgot, and won't seen on global environment. carpart<- car[,c(1,2,3,4)]





This way you can define the subsets, i e you made your own dataset from the previous one.

Point data manipulation

You can do point data editing in R, before you doing this you should have a better understanding on datasets you are dealing with. For this you have to specify both rows and columns.

just typecar[3,3] # 3rd row and 3rd column


check the output[1] 108





Suppose you could change the value from 108 to 50car[3,3]<- 50





Change row names and column names

Row names can be changed by function rownames(), lets the check the subset data "carpart" with rownames.




check resultrownames(carpart)
[1] "Mazda RX4" "Mazda RX4 Wag" "Datsun 710" "Hornet 4 Drive" "Hornet Sportabout"
[6] "Valiant" "Duster 360" "Merc 240D" "Merc 230" "Merc 280"
[11] "Merc 280C" "Merc 450SE" "Merc 450SL" "Merc 450SLC" "Cadillac Fleetwood"
[16] "Lincoln Continental" "Chrysler Imperial" "Fiat 128" "Honda Civic" "Toyota Corolla"
[21] "Toyota Corona" "Dodge Challenger" "AMC Javelin" "Camaro Z28" "Pontiac Firebird"
[26] "Fiat X1-9" "Porsche 914-2" "Lotus Europa" "Ford Pantera L" "Ferrari Dino"
[31] "Maserati Bora" "Volvo 142E"


If you want to know column names, you can use two commands> colnames(carpart) # colnames is a specific function
[1] "mpg" "cyl" "disp" "hp"
> names(carpart)# names only work work for dataframes
[1] "mpg" "cyl" "disp" "hp"


You can change the column names/row names by assign the new names in order, lets check the column names. > names(carpart)
[1] "mpg" "cyl" "disp" "hp"



Now assign with new name.names(carpart)<- c("miles/gal","cylinder","displacement","horsepower")
# or
colnames(carpart)<- c("miles/gal","cylinder","displacement","horsepower")


let's check the new column names




I hope this will you make you start the R program from scratch, More advanced topics are coming soon. Please follow the category R-spells.




Python: A Guide to Customizing Themes in Jupyter

  Hey there, Folks! It's been a while, hasn't it? Today, I'm excited to share a neat trick that'll make your Jupyter Lab or...