Take the 2-minute tour ×


Initially in my question I asked how I could search the database of AstronomicalData["Exoplanets"] and return 2 filtered values that only contained valued cases, which would be placed into a ListLogPlot. The necessity was to achieve 3 lists that had 2 sets of data, however my method required having to manually copy the results into their lists that didn't contain _Missing data.

The lists required categorization of the radii of exoplanets in relation to Jupiter and Neptune;

  • Exoplanets that are larger than Jupiter, exoplanet > Jupiter
  • Exoplanets that are larger than Neptune but smaller than Jupiter, Neptune < exoplanet < Jupiter
  • Exoplanets that are smaller than Neptune, exoplanet < Neptune

As an example, I sorted the radii by value to make finding correlating sizes easier, my search method was;

Sort[{AstronomicalData[#, "Radius"],AstronomicalData[#,"SemimajorAxis"]}->#&/@AstronomicalData["Exoplanet"]]

An extract from the example returns;

{3.63*10^6, 2.25*10^9} -> "KOI961d", {4.65*10^6, 8.75*10^8} -> "KOI961c"...

I found no concept which allowed me to use DeleteCases that allowed me to keep the syntax for naming using #

share|improve this question
add comment

2 Answers

There are a lot of ways to do that, for example:

name = AstronomicalData["Exoplanet"];
radius = AstronomicalData["Exoplanet", "Radius"];
a = AstronomicalData["Exoplanet", "SemimajorAxis"];
planet = {#, AstronomicalData[#, "Radius"]} & /@ {"Neptune", "Saturn"};

data = DeleteCases[Transpose[{name, radius, a}],
                   {_, Missing["NotAvailable"], _}];
data = Join[data, planet];
data = SortBy[data, #[[ 2]] &];
pos = Position[data, #][[ 1, 1]] & /@ {"Neptune", "Saturn"}
{24, 39}
data = data[[ #]] & /@ {;; 23, 25 ;; 38, 40 ;;};

ListPlot[data[[ ;; , ;; , {2, 3}]], AxesLabel -> {"radius", "semimajoraxis"}, 
         BaseStyle -> {Bold, 15, FontFamily -> "Arial", AbsolutePointSize@10},
         PlotRange -> All]

enter image description here

share|improve this answer
At quick glance that seems to fit the spot perfectly. I didn't proof my question and realized that I was missing several steps. I'm just in the process of recreating the task at hand and want to provide a better explanation, I believe I was asking the question in too much depth and too little understanding. I'll update soon. Thank you. –  Ashley James Jan 10 at 8:05
That example worked perfectly, many thanks it was easy to adapt and learned a few things along the way. I am going to make great use of the Join[] function, the Position[] function took me a bit to grasp but I got it sorted. Many thanks again for a great solution. –  Ashley James Jan 10 at 8:55
@AshleyJames I'm glad you find this useful. Notice that this is not the fastest approach but it does not matter here since the data set is small, comparing to average astronomical database :P Good luck. –  Kuba Jan 10 at 9:03
add comment
up vote 0 down vote accepted

I was able to produce an alternate method using Part and Select returning my desired results. The alternative requires less variables and I found it easier to work with.

Using Part I was able to selectively filter elements from the compiled lists:

data = Transpose[{AstronomicalData["Exoplanet", "Radius"], AstronomicalData["Exoplanet", "SemimajorAxis"], AstronomicalData["Exoplanet"]}];
data = DeleteCases[data[[All, 1 ;; 2]], {___, _Missing, ___}];
planets = {AstronomicalData[#, "Radius"], AstronomicalData[#, "SemimajorAxis"]} & /@ {"Jupiter", "Neptune", "Earth"};

From there I used Select to further compile lists which I could use to compare elements with:

Select[data, #[[1]] > planets[[1, 1]] &], (* radii>Jupiter*)
Select[data, #[[1]] > planets[[2, 1]] && #[[1]] < planets[[1, 1]] &],  (* Neptune>radii<Jupiter*)
Select[data, #[[1]] > planets[[3, 1]] && #[[1]] < planets[[2, 1]] &], (* radii>Earth<Neptune *)
Select[data, #[[1]] < planets[[3, 1]] &], (* radii<Earth *)

Due to limitations in the results from the database, I selectively disregarded adding the planets into data, however they could be added in one of two ways using:

data = Join[planets,data]; (* join elements *)
planets[[1]], (* add list to plot *)
share|improve this answer
add comment

Your Answer


