Sunday, February 18, 2018

Nice sayings I like

This weekend is the Chinese new year, happy new year everyone! I don't know what to write, therefore, I will turn this week's post into a page to keep the nice sayings I really like:
  • To begin, begin. - William Wordsworth
  • Sooner or later, those who win are those who think they can. - Paul Tournier
  • The finest steel has to go through the hottest fire. - Richard M. Nixon
  • It’s always too early to quit. - Norman Vincent Peale
  • There are many ways of going forward, but only one way of standing still. - Franklin D. Roosevelt 
  • Love the giver more than the gift. - Brigham Young
  • The only way to discover the limits of the possible is to go beyond them into the impossible. - Arthur C. Clarke
  • Man is so made that when anything fires his soul, impossibilities vanish. - Jean de La Fontaine
  • Be faithful to that which exists within yourself. - Andre Gide
  • Curiosity will conquer fear even more than bravery will. - James Stephens
  • Dreams are necessary to life. - Anais Nin
  • When your work speaks for itself, don't interrupt. - Henry J. Kaiser
  • Every failure is a step to success. - William Whewell
  • We must make the best of those ills which cannot be avoided. - Clarence Day
  • Our entire life - consists ultimately in accepting ourselves as we are. - Jean Anouilh
  • It is not how old you are, but how you are old. - Jules Renard
  • Don't think, just do. - Horace
  • It's better to be a lion for a day than a sheep all your life. - Elizabeth Kenny
  • Failure is success if we learn from it. - Malcolm Forbes
  • Millions saw the apple fall, but Newton was the one who asked why. - Bernard Baruch
  • Believe and act as if it were impossible to fail. - Charles Kettering
  • The art of being happy lies in the power of extracting happiness from common things. - Henry Ward Beecher
  • The less you talk, the more you're listened to. - Pauline Phillips
  • One faces the future with one's past. - Pearl S. Buck
  • Cherish your human connections: your relationships with friends and family. - Joseph Brodsky

Sunday, February 11, 2018

Paper: Structural Health Monitoring of Buildings Using Smartphone Sensors

Recently, our new paper - Structural Health Monitoring of Buildings Using Smartphone Sensors is out, which is part of our exploration of what MyShake data could be used.
Think about this: most of the smartphones will be used inside a building, for example, at night, your phone is in your building, and during the day, it is likely to be in your office building. If we could utilize the phones in the building to record the movement of the building during the earthquake, could we monitor the health state of the buildings? This is what we want to show in the paper by doing a shaker test, which you can find the description from my previous blog.
In the paper, we propose to use the smartphones to potentially extract the fundamental frequency of the building before and after the earthquake as a way to monitor the health state of the building. Why the fundamental frequency change can work as an indicator of the health state of the building? Let’s have a look below.
If we think we use a tractor pull the house with a rope, and what will happen if we cut the rope suddenly?
The building will start to move back and forth for a while as shown in the above picture. It is basically can be seen as an inverted pendulum that could oscillate at a certain frequency (or period if you are more familiar with this, the period is just 1/frequency). The building will move back and forth at certain period T, but with a decaying amplitude of the shaking.
Bud different buildings have different characters in terms of oscillation, some oscillate with high frequency (fast) and some oscillate with low frequency (slow) as shown in the above figure. A rule of thumb is the taller the buildings are, the lower frequency they are. The fundamental frequency reflects the nature of the building, with softer building have lower frequency.
Different earthquakes may cause various damages to the same building, with larger earthquakes causing more damage. These damages to the building will cause the building become softer, thus change the fundamental frequency of the building decrease.
Therefore, if we know the fundamental frequency of the building before an earthquake, and we could measure the fundamental frequency of the building during the earthquake, we may get a sense of how much the building damaged during the earthquake. This is our idea of using smartphone sensors to extract the fundamental frequency of the building during the earthquake, you could see the details in the paper.
Of course, there are still a lot of things need to be done to prove it, for one example, how do we find out which floor the phones are. But we do think that the smartphones to monitor the buildings is promising.
The first figure I found online, but I couldn’t remember from where, but I thank the authors for making this image. For the rest of the images, it is all from NICEE - Earthquake Tips, which is a very nice series about the basics of earthquake engineering.

Sunday, February 4, 2018

Using ArcGIS Online to create interactive map and share it easily

We talked how to use QGIS to generate a map with population and seismicity. This week, we will talk generate a similar map using ArcGIS online, but much easier steps and an easy sharing option. I think for creating a simple map, it is free, but if you want more advanced features, then it does cost to use it. I will show the free part of it, creating a simple map and share it. I will first show the results from it, you can get access to the map via this link. I can also embed this map here to show you how easy we can share an interactive map with the world using this method (try to move to different regions, or click the earthquake on the map):

How to make it

Now, I will show you how did I make it.

Step 1 Create a map

This step is relatively easy, you go the ‘Content’ tab after you signed in, and click the ‘Create’ button, and choose ‘Map’ as shown in the following figure:
Then you fill in all the informaiton about this map:

Step 2 Add the population data

After you filling in all the information to create a map, you will see something similar to the map below, and choose ‘Search for layers’ from the ‘Add’:
There are many layers online already, especially on the ArcGIS Online, therefore, let’s just search gpwv4 on the ArcGIS Online.
After I select the ‘GPWV4 Population Density, 2010’ layer, you can see the population data will show directly on the map. So simple!

Step 3 Add the earthquake data

Now, let’s add the earthquake data (I’ve already downloaded the worldwide earthquakes larger than M6 from 2006 to 2018, you can find it here). This time, we can directly add data from our local file, you can see the following two figures.
After you import the layer, you can see the earthquake data on the map (I was lazy to change the zoom in level on the map, therefore, you see them all squeeze into the center, you can just change it)

Step 4 Change the style

As we showed before, we want to show the earthquakes in different colors to represent depths and different sizes as magnitudes. We can do this by choose the magnitude as the attribute to show (there are many attributein the earthquake csv file)
We can add ‘depth’ as the other attribute we want to display:
Now we can see in the above figure that the system automatically shows different colors as magnitudes and sizes as the depth, let’s swap them:
We can change the fill color for the depth, and move the breaks on the left panel to set which color corresponding to the different depths, here I choose 100, which results in a legend 0 to 50, and 50 to 100, and 100 above. But I didn’t figure it out how to add more breaks, let me know if you know how to do it.
Do similar thing for the depth:
After you finish changing the depth and magnitude, now you can see we have a very nice map:
Select the Legend to see the legend for different data:

Step 4 Share the map

After you finish the map, you can easily share the map by just click the share button, if you choose everyone, anyone with the link showing there can get access to your map. Also, you can embed the map to your website as well:

More features

When you play with the map, you will soon find some more useful features, for example, if you click the one earthquake, you will find that all the information in the csv file for this earthquake will be shown in the popup window:
Also, if you don’t like the background map, you can easily change it by choosing different ones from the Basemap:
I hope you find this is useful.

Sunday, January 28, 2018

Learning QGIS: Change the style of the layers

Continue from last week, we have the population and earthquake data in QGIS, which looks like the following:

Change the color of population

We can see that the background population basically is black. The first thing we want to do is to change it so that the population will be shown as different colors based on the count of the population. We can achieve this by changing that in the style tab in the properties of this layer (you should remember how to find it, right? Just right click the, and choose the properties).
Let’s change the Render type to ‘Singleband pseudocolor’, and change the Color to ‘Oranges’. You can see that QGIS will automatically order generate a list of colors based on different population count. Of course, you can click the ‘Edit’ near the color to change the bins of the divide, that is how many colors you want. Also, you can change the value for each color to the one you want to divide, for example, I want the first color is 0, and the 2nd color is 0 to 100. All you need to do is to click the value for the 1st and 2nd value, and change to the values you prefer. Since the automatic values look good to me, I will not change it here. After you click ‘Ok’ button, you will see the map showing the population based on the colormap we just selected: the denser the population, the darker red it is, as shown in the following figure.

Show depths and magnitude for earthquake data

change the color

Now, we want to change the earthquake data as well: we want the color of the circle to show different depths, and the size of the circle to show the magnitude of the earthquake. Basically, we want the deeper the earthquakes are, the darker the colors are, and the larger the size of the circles, the higher magnitudes of the earthquakes. Let’s do the color first. We do this in the style tab for the earthquake layer.
As shown in the above figure, we change the style to ‘Graduated’, and choose the ‘Column’ as depth. We also change the method to ‘Color’, and select the color ramp as we want. This is telling the QGIS that we want to do the graduated color based on the depth column. After this, you can click the ‘Classify’ button. You will see the different value levels will have a different color. Note that, I select the ‘Mode’ as Pretty Breaks, you can play with other options or manually change it. Now click ‘Ok’, you will see the following figure that earthquakes are color-coded with the depth now.

change the size

Now, let’s change the size of the earthquakes. We go back to the style tab in the properties. Click the ‘Symbol Change …’, which will bring the Symbol selector as shown in the following figure:
Now click the icon to the right of the ‘Size’, which will bring up a dropdown list. Select the ‘Size Assistant…’:
Change the field to ‘mag’ and you can also change the ‘Size from’ and ‘Values from’ as you prefer, as shown in the following image:
After you set the size, and you can see that your earthquakes now have different sizes based on the magnitude:
Expand the earthquake layer in the ‘Layers Panel’, you can find your legend there:
Now, you have a nice map of showing the population in different colors and the earthquakes with different depth and magnitude.

Sunday, January 21, 2018

Learning QGIS - Import data and change projection

I am currently learning QGIS by attending the workshop at D-Lab, Geospatial Data and Mapping Fundamentals. Here I am using a small project to show what I learned the basics.
The goal of this small project is to make a map with the population count and the earthquakes worldwide, so that we can easily see where are the most dangerous places on earth.

Data download

First we need to download the population grid count data from Socioeconomic Data and Applications Center, I downloaded the population count data for 2015 at the resolution about 110km for demonstration purposes (you can download more higher resolution ones), you can find the population count data in GeoTiff here. And the earthquake data by query USGS catalogs, I’ve already downloaded the worldwide earthquakes larger than M6 from 2006 to 2018, you can find it here.

Import data into QGIS

Let’s load the data into the QGIS first. Since the population data is a GeoTiff, which is a raster file, we can add a raster layer as shown in the following figure:
The earthquake data is a vector data, and it can be added as a vector layer as the following figure, the QGIS is smart enough to find out the latitude and longitude as the Y and X field. You don’t need to change anything:
After we add the earthquake data, it now looks like this:

Change the projection

Many times, you will find that different data will have different projections. In a simple sense, the projection is the rule when you want to show things on the earth (3D sphere) onto a 2D Map. There are different projections, and if your data are in different projections, they will not line up in the map. Therefore, you need to make all the layers have the same projection.
You can find the projection of the data by right click the layer in the ‘Layers Panel’, and click the properties. The projection of this layer will be shown in the ‘General’ tab. As shown in the next two figures:
Note that, you can not change the projection here (even you change it here, the underlying projection is still the old one). If you want to change the projection, do the following steps:
Step 1:
Right click the layer you want to change the projection, and choose ‘Save as’:
Step 2:
A popup window will ask you the new name you want to save, and in the ‘CRS’, you can choose your new projection system.
Click the small global near it, and in the popup window, you can type ‘4326’ in the ‘Filter’, which will list the name of the projection system below. (in our case, we don’t need to change, but if you need change to another projection, just find it here)
Step 3:
After you save it as a new layer, you will see that in the ‘Layers Panel’. Remove the old layer:
Then you will have all the new layer with the new projections. Do this for all the layers in different projections (usually you change the vector layers to the projection system which the raster layer use)
Dada, we can see the above figure, we have the data loaded into the QGIS, but the population is all black, we want to change the color of the population based on the count, and for the earthquakes, maybe use the size of the circle as the magnitude and color it by using the depth. How we can do this? We will talk this next week.

Saturday, January 13, 2018

Convert word document to PDF with hyperlinks on Mac

Recently, I need to generate a PDF from a word document on Mac with hyperlinks in it. I found that if I directly print it to PDF, the hyperlinks will not work anymore. It searched online, and found two ways that I can have the hyperlinks work again.

First my system:
OS X Yosemite (10.10.5)
Microsoft office 2011

The solution:
Option A - Don't need internet

If you have Pages installed on your Mac, you can directly load the word document with Pages, and export it as PDF. You will happily see the hyperlinks work!

Option B - Need internet

Open a new google doc, and from the File->Open, this will open the word document in the google doc. Then choose File->Download, select as PDF. This way will output the PDF with the valid hyperlinks.

Friday, January 5, 2018

2018 - I am coming

How time flies! We are at 2018! Happy new year, everyone!

Look back of last year, I feel I am really lucky to have so much different experiences, the selected highlights are:

  • I had a faculty job interview at one university, even though I didn't get the job, I learned so much from the experience. This will be really useful for the future. 
  • I took a course at Berkeley to learn entrepreneurship. It is an eye opener course that have many different things than that in doing research. I also found a lot of the things I learned from this course could be applied back to research as well. 
  • My son was born before the summer starts, now I have a daughter and son! Task completed!
  • I attended the NSF I-Corps program, very intensive and so unique that I will never forget the moments during the 7 weeks! Since I talked to about ~140 people within a very short time, a byproduct is that I will not be shy anymore to talk with anyone in the world ^_^
  • I visited Harvard, MIT, and BU, and tasted the different flavors of the 3 great universities! I really love the city - Boston! 
  • I bought a full size 88 weighted key piano, and started to learn! So much fun with it!
  • Last, but not the least, my first AGU outside of SF! And my first time to serve as a session chair, so proud!
2018, a big year ahead of me. I don't know what will happen, but I know, if I continue to work hard, and luck will come! Enjoy work, enjoy life! 2018, I am coming!