Re: Interrogating lists of unequal lenghths
- To: mathgroup at smc.vnet.net
- Subject: [mg67428] Re: Interrogating lists of unequal lenghths
- From: "kevin_jazz" <kevinbowman at mac.com>
- Date: Fri, 23 Jun 2006 04:31:55 -0400 (EDT)
- References: <e7aou4$92n$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Thanks to everyone for the submission. I think simply mapping
dimensions works. I'm still new at this so even the obvious solutions
aren't evident until demonstrated. For my actual problem
Dimensions /@ aura3399com
{{70}, {125, 67}, {125, 67}, {125}, {125, 67, 67}, {125,
67}, {125}, {125, 25}, {125, 25}, {125}, {125}, {125}, {125, 67}, {
125}, {125}, {125}, {125, 67}, {125}, {125}, {125}, {125,
67, 67}, {125}, {125, 67}, {
125, 67}, {125, 67, 67}, {
125, 67}, {125}, {125}, {125}, {125}, {125}, {125}, {125}, {125},
{125}, {
125}, {125}, {125}, {125}, {125}, {125}, {
125}, {125}, {125}, {125}, {125, 67}, {125,
67, 67}, {125, 67}, {125}, {125}, {125}, {125}, {125}, {125}, {
125}, {125}, {125}, {
125}, {125}, {125}, {125}, {125}, {125}, {125}, {125}, {125},
{125}, \
{125}, {125}}
I'm working on building a structure for HDF5 data, specifically for the
NASA Aura spaceplatform, so I just figured out how to do this:
TableForm[Transpose[{aura3399com[[1]],
Map[Dimensions, aura3399com][[Table[
i, {i, 2, Length[aura3399com]}]]]}], TableAlignments -> {Left,
Top}]
Out[60]//TableForm=
AirDensity 125
67
Altitude 125
67
AverageCloudEffOpticalDepth 125
AveragingKernel 125
67
67
AveragingKernelDiagonal 125
67
Calibration_QA 125
CloudEffectiveOpticalDepth 125
25
CloudEffectiveOpticalDepthError 125
25
CloudTopPressure 125
CloudTopPressureError 125
CloudVariability_QA 125
ConstraintVector 125
67
DegreesOfFreedomForSignal 125
DeviationVsRetrievalCovariance 125
InformationContent 125
Initial 125
67
KDotDL_QA 125
LDotDL_QA 125
MaxNumIterations 125
MeasurementErrorCovariance 125
67
67
NumberIterPerformed 125
O3 125
67
O3Precision 125
67
ObservationErrorCovariance 125
67
67
Pressure 125
67
RadianceResidualMax 125
RadianceResidualMean 125
RadianceResidualRMS 125
Scan_Averaged_Count 125
SpeciesRetrievalConverged 125
SpeciesRetrievalQuality 125
SurfaceEmissMean_QA 125
SurfaceTempConstraint 125
SurfaceTempDegreesOfFreedom 125
SurfaceTempError 125
SurfaceTempInitial 125
SurfaceTempObservationError 125
SurfaceTempPrecision 125
SurfaceTempVsApriori_QA 125
SurfaceTempVsAtmTemp_QA 125
SurfaceTemperature 125
TotalColumnDensity 125
TotalColumnDensityError 125
TotalColumnDensityInitial 125
TotalError 125
67
TotalErrorCovariance 125
67
67
VerticalResolution 125
67
BoresightAzimuth 125
BoresightNadirAngle 125
BoresightNadirAngleUnc 125
DayNightFlag 125
DominantSurfaceType 125
Latitude 125
Latitude_Footprint_1 125
Latitude_Footprint_2 125
Latitude_Footprint_3 125
Latitude_Footprint_4 125
LocalSolarTime 125
Longitude 125
Longitude_Footprint_1 125
Longitude_Footprint_2 125
Longitude_Footprint_3 125
Longitude_Footprint_4 125
Scan 125
Sequence 125
SolarZenithAngle 125
SurfaceElevStandardDeviation 125
SurfaceTypeFootprint 125
Tgt_SpacecraftAzimuth 125
Tgt_SpacecraftZenith 125
So, this allows me to figure out what elements are matrices or vectors.
I think the depth will be good when the lists contain other objects as
well. It would also be good to tell if the data is a string or a
number.
Many thanks,
Kevin
Bill Rowe wrote:
> On 6/20/06 at 2:15 AM, kevinbowman at mac.com (kevin_jazz) wrote:
>
> >I'm trying to understand how to assess the dimensions of a list
> >containing elements of unequal length. Let's say I have the list
>
> >U If, on the other hand, I set up the following list
>
> >In[5]:= x={{1},{2,3},{4,5,6,7}}
>
> >In[6]:= Dimensions[x]
>
> >Out[6]= {3}
>
> >The Dimensions command tells me I have only 3 elements. But, I need
> >some way to figure out that the first sublist has length 1, second
> >has length 2, and the third has length 4 in some automated fashion.
> >I've looked through the other commands like Depth and Length but I
> >don't see anything that does this.
>
> It seems to me there are two reasonably simple possibilities. You might do
>
> In[2]:=
> {Depth@#-1,Length@#}&/@x
>
> Out[2]=
> {{1, 1}, {1, 2}, {1, 4}}
>
> which returns a result similar to dimensions, That is the first number specifies the number of rows in the element and the second the number of columns for the element (number of sub-elements). By using Depth you will be notified is one of the elements in x isn't a vector.
>
> But if you are certain each element of x will be a vector than simply doing
>
> In[3]:=
> Length/@x
>
> Out[3]=
> {1,2,4}
>
> should suffice
> --
> To reply via email subtract one hundred and four