Re: [julia-users] create a multi data type structure in Julia

2015-02-04 Thread alex codoreanu
What I ended up implementing is a dict that can be dynamical created. 
Here's the code for it but the dict member are blank initialised. 

# names of parameters to be based to make_dictionary
ttype_names_final = {
 LAMBDA   
 EW   
 SIGMA1_RESULT
 SIGMA3_RESULT}

   @eval  function $(symbol(string(make_dictionary)))()
new_dict = Dict{Symbol,Any}()
 println(making new dictionary)
  
# create new dictionary with each field empty
 for sym in ttype_names_final
   new_dict[symbol(sym)] = []
end

  return new_dict
  end


*a = make_dictionary()*

making new dictionary

*Dict{Symbol,Any} with 4 entries:*

*  :EW= None[]*

*  :LAMBDA= None[]*

*  :SIGMA1_RESULT = None[]*

*  :SIGMA3_RESULT = None[]*

On Tuesday, February 3, 2015 at 3:07:43 AM UTC+11, alex codoreanu wrote:

 Hi Tim,

 I am actually trying to use the low-level functionality provided in 
 FITSIO.jl to write a higher-level function that can deal with fits files 
 with an unknown number of columns and a mix of datatypes. 

 Fingers crossed!

 On Sunday, February 1, 2015 at 10:33:47 PM UTC+11, Tim Holy wrote:

 Have you seen 
 https://github.com/JuliaAstro/FITSIO.jl 

 Off-topic, but it would be awesome to have FITS integrated into 
 Images.jl. I 
 could help with the integration, but it is pretty well documented: 
 https://github.com/timholy/Images.jl/blob/master/doc/extendingIO.md 
 Further discussion could happen at 
 https://github.com/JuliaAstro/FITSIO.jl/issues/18 

 --Tim 

 On Sunday, February 01, 2015 12:35:53 AM alex codoreanu wrote: 
  Hi all, 
  
  I'm a new Julia user and I'm starting to write a high-level multi data 
 type 
  fits file reader and writer akin to IDL's mwrfits/mrdfits. I got most 
 of 
  the dynamics figured out by I can't quite make a custom structure. For 
  example, I would like something like: 
  
  element = {name::string, lambda::[float_array, 5000 elements], 
  flux::[float_array, 5000 elements]} 
  
  structure = replicate(element, 500) 
  
  where structure inherits the members of element and can be called, 
  
  structure[1].name = the name of element 1 
  strucutre[1].lambda[1] = the first lambda element of the first 
 structure 
  
  
  Thanks !!! 



[julia-users] erase previous instance of type

2015-02-02 Thread alex codoreanu
Hi,

I am trying to figure out how to erase a previous instance of a type 
definition. I am writing a function that can dynamically alocate For 
example:

instance 1
type data_return_type
   spec_name::String
   lambda::Vector(Float32}
   spec::Vector(Float32}
end


[julia-users] dynamically create a type definition

2015-02-02 Thread alex codoreanu
Hi,

I am trying to figure out how to erase a previous instance of a type 
definition. I am writing a function that can dynamically create a 
return_type based on the variables passed to it. For example:

instance 1
type data_return_type
   spec_name::String
   lambda::Vector(Float32}
   spec::Vector(Float32}
end

instance 2
type data_return_type
   spec_name::String
   lambda::Vector(Float32}
   spec::Vector(Float32}
   continuum::Vector(Float32}
end


The problem I am having is that I get the message:

 Invalid redefinition of constant type data_return_type

so I would like to erase the previous instance of data_return_type or is 
there a more traditional way to create a structure?



Thank you!


Re: [julia-users] create a multi data type structure in Julia

2015-02-02 Thread alex codoreanu
Hi Tim,

I am actually trying to use the low-level functionality provided in 
FITSIO.jl to write a higher-level function that can deal with fits files 
with an unknown number of columns and a mix of datatypes. 

Fingers crossed!

On Sunday, February 1, 2015 at 10:33:47 PM UTC+11, Tim Holy wrote:

 Have you seen 
 https://github.com/JuliaAstro/FITSIO.jl 

 Off-topic, but it would be awesome to have FITS integrated into Images.jl. 
 I 
 could help with the integration, but it is pretty well documented: 
 https://github.com/timholy/Images.jl/blob/master/doc/extendingIO.md 
 Further discussion could happen at 
 https://github.com/JuliaAstro/FITSIO.jl/issues/18 

 --Tim 

 On Sunday, February 01, 2015 12:35:53 AM alex codoreanu wrote: 
  Hi all, 
  
  I'm a new Julia user and I'm starting to write a high-level multi data 
 type 
  fits file reader and writer akin to IDL's mwrfits/mrdfits. I got most of 
  the dynamics figured out by I can't quite make a custom structure. For 
  example, I would like something like: 
  
  element = {name::string, lambda::[float_array, 5000 elements], 
  flux::[float_array, 5000 elements]} 
  
  structure = replicate(element, 500) 
  
  where structure inherits the members of element and can be called, 
  
  structure[1].name = the name of element 1 
  strucutre[1].lambda[1] = the first lambda element of the first structure 
  
  
  Thanks !!! 



Re: [julia-users] dynamically create a type definition

2015-02-02 Thread alex codoreanu
Hi Kyle, 

DataFrames is an option if I restructure my data around it. This structure 
issue is important for the data.fits file reader but Stefan had a good 
suggestion about wrapping up the type definition in a module call. However, 
it's getting close to sun-up in Australia so I'll sleep on it for a bit.

Alex


On Tuesday, February 3, 2015 at 3:39:19 AM UTC+11, Kyle Barbary wrote:

 Hi Alex,

 Correct me if I'm wrong, but I think what you're looking for is the 
 equivalent of a numpy structured array: an array where each element is a 
 composite data structure. Normally in Julia, you'd use an array of your 
 custom type to achieve this. However, the desire here is that the fields 
 and types of the data structure can be determined at runtime according to 
 the contents of a file, for example.

 You might want to look at the DataFrames package, and particularly at this 
 issue:
 https://github.com/JuliaStats/DataFrames.jl/issues/744

 - Kyle

 On Mon, Feb 2, 2015 at 8:15 AM, alex codoreanu alex.co...@gmail.com 
 javascript: wrote:

 Hi,

 I am trying to figure out how to erase a previous instance of a type 
 definition. I am writing a function that can dynamically create a 
 return_type based on the variables passed to it. For example:

 instance 1
 type data_return_type
spec_name::String
lambda::Vector(Float32}
spec::Vector(Float32}
 end

 instance 2
 type data_return_type
spec_name::String
lambda::Vector(Float32}
spec::Vector(Float32}
continuum::Vector(Float32}
 end


 The problem I am having is that I get the message:

  Invalid redefinition of constant type data_return_type

 so I would like to erase the previous instance of data_return_type or is 
 there a more traditional way to create a structure?



 Thank you!




[julia-users] create a multi data type structure in Julia

2015-02-01 Thread alex codoreanu
Hi all,

I'm a new Julia user and I'm starting to write a high-level multi data type 
fits file reader and writer akin to IDL's mwrfits/mrdfits. I got most of 
the dynamics figured out by I can't quite make a custom structure. For 
example, I would like something like:

element = {name::string, lambda::[float_array, 5000 elements], 
flux::[float_array, 5000 elements]}

structure = replicate(element, 500)

where structure inherits the members of element and can be called,

structure[1].name = the name of element 1
strucutre[1].lambda[1] = the first lambda element of the first structure


Thanks !!!


Re: [julia-users] create a multi data type structure in Julia

2015-02-01 Thread alex codoreanu
Thanks Milan, 

I defined Element as you suggested and created

*data=(Element, 2)*

but 

*julia **data[1].lambda=[1., 2.0]*

*ERROR: type DataType has no field lambda*

Now that I have the structure data how do I access the branch members?


On Sunday, February 1, 2015 at 8:07:51 PM UTC+11, Milan Bouchet-Valat wrote:

 Le dimanche 01 février 2015 à 00:35 -0800, alex codoreanu a écrit : 
  Hi all, 
  
  
  I'm a new Julia user and I'm starting to write a high-level multi data 
  type fits file reader and writer akin to IDL's mwrfits/mrdfits. I got 
  most of the dynamics figured out by I can't quite make a custom 
  structure. For example, I would like something like: 
  
  
  element = {name::string, lambda::[float_array, 5000 elements], 
  flux::[float_array, 5000 elements]} 
  
  
  structure = replicate(element, 500) 
  
  
  where structure inherits the members of element and can be called, 
  
  
  structure[1].name = the name of element 1 
  strucutre[1].lambda[1] = the first lambda element of the first 
  structure 
 Looks like a composite type would work: 

 type Element 
 name::UTF8String 
 lambda::Vector{Float64} 
 flux::Vector{Float64} 
 end 



 Regards 



Re: [julia-users] create a multi data type structure in Julia

2015-02-01 Thread alex codoreanu
That worked but I had to use:

data = Array(Element, 2) 

Thanks for the info!



On Sunday, February 1, 2015 at 8:57:23 PM UTC+11, Milan Bouchet-Valat wrote:

 Le dimanche 01 février 2015 à 01:24 -0800, alex codoreanu a écrit : 
  Thanks Milan, 
  
  
  I defined Element as you suggested and created 
  
  
  data=(Element, 2) 
 What is this line supposed to do? All it does now is assign a tuple 
 containing the Element type, and the integer value 2. 

 If you want to create an Element instance, you should do e.g.: 
 element = Element(a name, [1, 2], [2, 3]) 

 and then to create a list holding two Elements, and fill the first value 
 with the just created element: 
 data = Vector(Element, 2) 
 data[1] = element 

 Accessing members: 
 data[1].lambda 


 Regards 


  but 
  
  
  julia data[1].lambda=[1., 2.0] 
  
  ERROR: type DataType has no field lambda 
  
  
  
  Now that I have the structure data how do I access the branch members? 
  
  
  
  
  On Sunday, February 1, 2015 at 8:07:51 PM UTC+11, Milan Bouchet-Valat 
  wrote: 
  Le dimanche 01 février 2015 à 00:35 -0800, alex codoreanu a 
  écrit : 
   Hi all, 
   
   
   I'm a new Julia user and I'm starting to write a high-level 
  multi data 
   type fits file reader and writer akin to IDL's 
  mwrfits/mrdfits. I got 
   most of the dynamics figured out by I can't quite make a 
  custom 
   structure. For example, I would like something like: 
   
   
   element = {name::string, lambda::[float_array, 5000 
  elements], 
   flux::[float_array, 5000 elements]} 
   
   
   structure = replicate(element, 500) 
   
   
   where structure inherits the members of element and can be 
  called, 
   
   
   structure[1].name = the name of element 1 
   strucutre[1].lambda[1] = the first lambda element of the 
  first 
   structure 
  Looks like a composite type would work: 
  
  type Element 
  name::UTF8String 
  lambda::Vector{Float64} 
  flux::Vector{Float64} 
  end 
  
  
  
  Regards 
  



[julia-users] Re: Adding Custom .jl through module calls

2015-01-27 Thread alex codoreanu
Thanks Mauro,

alex.readcol() worked !

*julia **a=alex.readcol(name_of_file)*



the object returned is a 10201.0 x 3 matrix



On Tuesday, January 27, 2015 at 9:19:22 PM UTC+11, alex codoreanu wrote:

 Hi guys,

 I'm a new user, 1st week :)  and I am having trouble properly accessing 
 some functions that I built. One of them is akin to IDL's readcol.pro.

 My module definition for alex.jl

 *module alex*

 *include(/Users/alex/CODES/Julia_Custom_jl/alex/src/readcol.jl)*
 *println(alex_module_loaded)*

 *end*

 After 

 *julia **using alex*

  alex_module_loaded


 *julia **readcol()*

 *ERROR: readcol not defined*

 the path and include is correct

 *julia *
 *include(/Users/alex/CODES/Julia_Custom_jl/alex/src/readcol.jl)*

 *readcol (generic function with 1 method)*

 so it looks like it might be a scope issue. I basically want to have 
 access to readcol() after loading my custom module.

 Thank you.



[julia-users] Adding Custom .jl through module calls

2015-01-27 Thread alex codoreanu
Hi guys,

I'm a new user, 1st week :)  and I am having trouble properly accessing 
some functions that I built. One of them is akin to IDL's readcol.pro.

My module definition for alex.jl

*module alex*

*include(/Users/alex/CODES/Julia_Custom_jl/alex/src/readcol.jl)*
*println(alex_module_loaded)*

*end*

After 

*julia **using alex*

 alex_module_loaded


*julia **readcol()*

*ERROR: readcol not defined*

the path and include is correct

*julia **include(/Users/alex/CODES/Julia_Custom_jl/alex/src/readcol.jl)*

*readcol (generic function with 1 method)*

so it looks like it might be a scope issue. I basically want to have access 
to readcol() after loading my custom module.

Thank you.