The discussion revolves around using Healpix in C++ to convert binary data into a visual map. Participants are exploring the necessary functions and methods to achieve this, particularly focusing on reading data, processing it, and visualizing it on a celestial sphere.
Discussion Character
Technical explanation
Exploratory
Homework-related
Main Points Raised
One participant expresses a need to convert binary data from a text file into a Healpix RING map but is unsure which function to use.
Another participant suggests clarifying whether the goal is to read the data for processing or to create a visual map.
Several participants highlight that Healpix is commonly used for spherical data sets and is particularly relevant for CMB analysis.
There are references to documentation and tutorials that may help in understanding the Healpix API and its functionalities.
One participant notes that while Healpix C++ is primarily designed for calculations, visualization is typically handled by other tools.
A suggestion is made to use the "map2tga" utility to create a map from a .fits file after writing the Healpix map to it.
A participant shares a code snippet and describes their approach to creating a map, but encounters an error related to the function call for writing to .fits.
Areas of Agreement / Disagreement
Participants generally agree on the utility of Healpix for spherical data and the need for specific functions to convert data to maps. However, there is no consensus on the best approach to integrate the visualization process within C++ code, and multiple views on how to handle the data and errors remain unresolved.
Contextual Notes
Participants mention that most Healpix files are in FITS format, which may affect how data is processed and visualized. There are also indications that the integration of visualization functions into C++ may be challenging for beginners.
#1
bluecrow
5
0
Hi.
At first,I am sorry that my English is so bad.
I've just installed Healpix on cxx(c++), and I'm starting to leraning.
then I made txt file containing binary data(RING pixel and corresponding to data like temperture),and I want to make Healpix RING map of the data.
Wow, this is an interesting piece of software. I've never heard of it before.
It's honestly really great for spherical data sets. It's ubiquitous for CMB analysis, which is I think what it's designed for. It's a method of efficiently storing spherical data where each pixel corresponds to an identical surface area on the sphere at any resolution, with minimal distortion.
#6
bluecrow
5
0
kimbyd said:
I'm a little unsure what you want to do. Do you want to:
a) Read in the text file to have it as Healpix data so you can do some processing?
b) Convert the binary data to a visual map you can view?
Edit: Also, where are you getting this file from? Most Healpix files are in FITS format, not txt.
Thank you for answering my question.
I want to do b, convert the binary data to a visual map I can view.Now I am calculating the exposure of satellite observation equipment,this file's data have width of several tens of degrees.and I want to depict on celestial sphere map.
Thank you for answering my question.
I want to do b, convert the binary data to a visual map I can view.Now I am calculating the exposure of satellite observation equipment,this file's data have width of several tens of degrees.and I want to depict on celestial sphere map.
Basically the way to do it is use Healpix C++ to write to fits (I recommend using the form of write_Healpix_map_to_fits() which takes a string, Healpix_Map<T>, and data type, documented here).
Once you've written it to a file, you can use the "map2tga" utility to create the map from the command line. Example command:
map2tga my_healpix_file.fits my_map.tga
There's lots of options that you can use to customize the resulting output.
#8
bluecrow
5
0
jedishrfu said:
Wow, this is an interesting piece of software. I've never heard of it before.
I already found their site,but I am beginner of cxx. So I want more detailed solution on cxx.
Reason why I use cxx is that previous research's program data is wrote by cxx. I want to connect two program.
That's a little bit more challenging, because Healpix C++ really wasn't designed to do that. It was more designed for doing calculations on Healpix maps. Visualization was left to other stuff.
It looks like your best bet is to call the map2tga module from within your code. I recommend doing what is done in the map2tga main function here:
#include "levels_facilities.h"
#include "error_handling.h"
// Lots of code
// Write Healpix map to .fits file
PLANCK_DIAGNOSIS_BEGIN
map2tga_module (argc, argv);
PLANCK_DIAGNOSIS_END
// Read image from TGA file using a library
// Clean up temporary .fits and .tga files
// Send image to destination // Other code
The problem with this is that if you call map2tga from within your C++ code like this, you still have to first output the .fits file to the filesystem, then call it from this module. It also writes the image to a .tga file, which you'd have to load a library to read.
Overall, it's going to be messy. Your only other option is to modify the map2tga code itself to create a new function which doesn't require file reads or writes. That won't be terribly easy to do. The place to start would be the module code, but I suspect it might be difficult for you if you're a beginner at C++: https://sourceforge.net/p/healpix/code/HEAD/tree/trunk/src/cxx/Healpix_cxx/map2tga_module.cc
Basically the way to do it is use Healpix C++ to write to fits (I recommend using the form of write_Healpix_map_to_fits() which takes a string, Healpix_Map<T>, and data type, documented here).
Once you've written it to a file, you can use the "map2tga" utility to create the map from the command line. Example command:
map2tga my_healpix_file.fits my_map.tga
There's lots of options that you can use to customize the resulting output.
Sorry for late reply.
Beased on your advice,I do something.But yet I don't understand way from data to map.
Please look my code. lot code...
I want to make MAP with cel(i) and want to make map2fits or map2tga ,but not going well.
if you want to know more information,please tell me.
<mentor: add code code tags>
ccc << i <<" "
<< cel << endl; //cel is defined cel[50000]
celsum=celsum+cel;
if(cel>celmax){
celmax=cel;
}
}
Healpix_Map<double> G(cel,RING);
write_Healpix_map_to_fits("result.fits",G,PDT); return 0;
}error:
[@localhost RADEC→exp]$ g++ cexp.cc -g -lhealpix_cxx -lcxxsupport -lsharp -lfftpack -lc_utils -lcfitsio
cexp.cc: ‘int main()’ 内:
cexp.cc:251:46: エラー: expected primary-expression before ‘)’ token
write_Healpix_map_to_fits("result.fits",G,PDT);
^
[@localhost RADEC→exp]$I want to make MAP with cel(i) and want to make map2fits or map2tga ,but not going well.
if you want to know more information,please tell me.
For Healpix_Map<double>, the value would be PLANCK_FLOAT64. So the call would be:
write_Healpix_map_to_fits("result.fits", G, PDT);
2) You write "6" many times. Store that in a variable (I recommend MAP_ORDER).
3) Store the values like "NSIDE and NPIX" in "const int" variables instead. They are integers, and they shouldn't change. So const int is the way to go.
4) It looks like you're generating a bunch of data, trying to store it in an array, then converting it to Healpix_Map, then writing it to FITS. Don't do this. Just create the Healpix_Map<double> from scratch. You can use code similar to the following:
Healpix_Map<double> map(MAP_ORDER, RING);Okay. It looks like you're attempting to generate some data, store it in "cel", then write the data to the Healpix_Map? If so, then there are definitely a few errors here. First, what are you attempting to store in the map?
With that said:
1) You should be storing values like NSIDE and NPIX as integers, as that's what they logically are. Definitely avoid using values like the number 6 in multiple places (makes it hard to change the code in the future). I would suggest creating a new variable, but it's probably not necessary to use this more than once.
2) You really shouldn't be storing data outside the Healpix_Map variable, then converting it to Healpix_Map. Write to the Healpix_Map directly.
For Healpix_Map<double>, the value would be PLANCK_FLOAT64. So the call would be:
write_Healpix_map_to_fits("result.fits", G, PDT);
However, you're treating cel like a variable rather than an array. That's going to cause some problems. However, it probably makes sense to just get rid of "cel" entirely. Instead, after you set up the NSIDE and NPIX values, go ahead and define a Healpix_Map<double> object. I recommend doing something like:
Code:
const int NSIDE=pow(2,6);
Healpix_Map<double> hp_map(NSIDE, RING, SET_NSIDE);
for (int i = 0; i < hp_map.Npix(); i++) {
pointing vec = hp_map.pix2vec(i);
// Calculate pixel value from vec.theta and vec.phi.
hp_map[i] = computed_value;
}
write_Healpix_map_to_fits("results.fits", healpix_map, PLANCK_FLOAT64);
If you'd also like to write the values to a text file for debugging (it looks like that's what you're attempting above, but I doubt it works properly), you can also include:
I can never thank you enough,It happened without a hitch.
by this case and your advice,I was able to learn how to use of healpix a little.
You gave me examples and it was easy to understand.
Thank you.
I can never thank you enough,It happened without a hitch.
by this case and your advice,I was able to learn how to use of healpix a little.
You gave me examples and it was easy to understand.
Thank you.